New issue
Advanced search Search tips

Issue 850007 link

Starred by 2 users

Issue metadata

Status: Duplicate
Merged: issue 717016
Owner:
Closed: Jul 5
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: Windows
Pri: 2
Type: Bug



Sign in to add a comment

instanceof not work on new window

Reported by baess...@gmail.com, Jun 6 2018

Issue description

UserAgent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36

Steps to reproduce the problem:
1. const newWindow= window.open()
2. add html on newWindow
3. find a node on html body on newWindow and check instanceOf HTMLElement. This will return false

What is the expected behavior?
instanceOf work with object subtypes on code running on new window

What went wrong?
all js libraries used on new window failed on every instanceOf check

Did this work before? N/A 

Chrome version: 66.0.3359.181  Channel: n/a
OS Version: 6.1 (Windows 7, Windows Server 2008 R2)
Flash Version:
 
Components: -Blink Blink>Bindings
Can you provide an example URI? In my simple testing (http://jsbin.com/labahub/edit?html,js,console,output) this appears to be true however I'm deferring to the bindings team.
Labels: Needs-Triage-M66

Comment 3 by baess...@gmail.com, Jun 7 2018

The same code return false on second log, on my chrome browser (see attached file).
Firefox ok.
Safari same problem
CatturaChrome.PNG
34.1 KB View Download
Cc: susan.boorgula@chromium.org
Labels: Triaged-ET Needs-Feedback
baesso91@ Thanks for the issue.

Tested this issue on Windows 10 and Mac OS 10.13.3 on the reported version and the latest Canary as per comment #1.

1. Launched Chrome and navigated to http://jsbin.com/labahub/edit?html,js,console,output.
2. Before allowing the popups on the page, can see Type Error on the Console.
3. After allowing the popups on the page, and reloading the page, a new tab is opened and the output in the Console of the previous tab is True, False.
Whereas in Firefox the output is True, True.

Attached is the screen cast for reference.

dtapuska@ Request you to check and update if anything is missed from our end in triaging the issue.

Thanks...
850007.mp4
948 KB View Download
Mergedinto: 717016
Owner: jbroman@chromium.org
Status: Duplicate (was: Unconfirmed)
Trivial repro: data:text/html,<iframe srcdoc=""></iframe><script>console.log(document.querySelector('iframe').contentDocument instanceof Document)</script>

We've run into this before. Basically what's going on here is that we're reporting the ECMAScript sense of instanceof: since the two frames have separate global objects, there are separate HTMLElement.prototype and so on. Since each is only on the prototype chain for elements of that context, OrdinaryHasInstance reports that it's not an instance.

Firefox continues to implement a behavior that has since been removed from the WebIDL spec, which overrode this behavior in the specific case of WebIDL interfaces.

See also:
https://github.com/heycam/webidl/pull/356
https://bugs.chromium.org/p/chromium/issues/detail?id=717016

And the Mozilla bug to match us:
https://bugzilla.mozilla.org/show_bug.cgi?id=1360715

And there's a WPT test (WebIDL/ecmascript-binding/has-instance.html) that asserts that this is so.

Sign in to add a comment