WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
NEW
202402
[GTK] 'instanceof' fails to identify objects properly inside an iframe
https://bugs.webkit.org/show_bug.cgi?id=202402
Summary
[GTK] 'instanceof' fails to identify objects properly inside an iframe
Milan Crha
Reported
2019-10-01 06:18:36 PDT
Using WebKitGTK+ 2.26.0, aka webkit-2.26 branch at
r249660
. Using 'instanceof' operator in JSC fails to properly identify objects, returning 'false' even for cases which are should return 'true', including console output. Steps to reproduce: a) open a Console tab in an inspector and issue this set of commands: document.documentElement.innerHTML = "<html><body>main<iframe id='frm1' src='empty:///'></iframe></body></html>"; document.getElementById("frm1").contentDocument.documentElement.innerHTML = "<html><body>frm1<iframe id='frm2' src='empty:///'></iframe></body></html>"; document.getElementById("frm1").contentDocument.getElementById("frm2").contentDocument.documentElement.innerHTML = "<html><body>frm1<iframe id='frm2' src='empty:///'></iframe></body></html>"; function checkit(elem) { if (elem) console.log("elem:" + elem + " tag:" + elem.tagName + " id:" + elem.id + " is iframe:" + (elem instanceof HTMLIFrameElement) + " is HTMLElem:" + (elem instanceof HTMLElement)); else console.log("elem is null");} b) try what checkit() returns for respective elements. The "quoted" string is what it writes in the console. checkit(document.documentElement);
> elem:[object HTMLHtmlElement] tag:HTML id: is iframe:false is HTMLElem:true
checkit(document.getElementById("frm1"));
> elem:[object HTMLIFrameElement] tag:IFRAME id:frm1 is iframe:true is HTMLElem:true
checkit(document.getElementById("frm1").contentDocument.getElementById("frm2"));
> elem:[object HTMLIFrameElement] tag:IFRAME id:frm2 is iframe:false is HTMLElem:false
I expect to see 'true' / 'true' at the end of the log above. checkit(document.getElementById("frm1").contentDocument.getElementById("frm2").contentDocument.getElementById("frm2"));
> elem:[object HTMLIFrameElement] tag:IFRAME id:frm2 is iframe:false is HTMLElem:false
Similarly here and below, where it tried the HTML document of the inner iframe-s, which should work the same as the first checkit() call above, I believe. checkit(document.getElementById("frm1").contentDocument.getElementById("frm2").contentDocument);
> elem:[object HTMLDocument] tag:undefined id:undefined is iframe:false is HTMLElem:false
checkit(document.getElementById("frm1").contentDocument);
> elem:[object HTMLDocument] tag:undefined id:undefined is iframe:false is HTMLElem:false
checkit(document.getElementById("frm1"));
> elem:[object HTMLIFrameElement] tag:IFRAME id:frm1 is iframe:true is HTMLElem:true
This just re-runs the working call from the above again. I doubt I do anything wrong, but I'm new to Javascript, thus I'll be happy to be corrected.
Attachments
Add attachment
proposed patch, testcase, etc.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug