You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
contentWindow always null for cross origin iframe #3939
<html><body><iframesrc="http://example.com" id="iframe"></iframe><script>variframe=document.getElementById('iframe');varintervalId=setInterval(function(){if(iframe.contentWindow){clearInterval(intervalId);console.log('done');return;}console.log('will try contentWindow again in a sec')},1000);</script></body></html>
It should just work (I'm using ugly setInteval because servo does not support load events on iframe). However, it does not as the iframe is cross origin.
I dug into this problem a little more and here's what I've found (thanks @jdm and @mrobinson):
In htmliframeelement.rs there's GetContentWindow which fails because child is None.
Why:
process_the_iframe_attributes sends a LoadIframeUrlMsg message to constellation
it is handled in constellation.rs by handle_load_iframe_url_msg
in our case (cross origin) new_pipeline is None
self.new_pipeline calls then Pipeline::create with script_pipeline set to None
pipeline.rs matches script_pipeline with None and does not send a AttachLayoutMsg to ScriptControlChan that normally then calls handle_new_layout which adds new_page to parent_page's children (and so GetContentWindow fails)
As I'm new to the project I'm not really sure as how to fix it. In particular I don't know how do we make scripts in frames having different global contexts. I'd welcome some references as what should I read to understand it.
It's possible that this is right-ish behaviour. I was investigating what Firefox does with contentWindow for cross-origin frames, and the resulting object is very locked down. Most properties throw permission errors if you try to access them, so we should potentially be creating a different Window-like object from contentWindow in this case if we can't find one.
What Gecko does here is return an Xray wrapper wrapper that has a restrictive security policy (with the security policy actually codegenned from IDL annotations).
Activity
jdm commentedon Nov 8, 2014
It's possible that this is right-ish behaviour. I was investigating what Firefox does with contentWindow for cross-origin frames, and the resulting object is very locked down. Most properties throw permission errors if you try to access them, so we should potentially be creating a different Window-like object from contentWindow in this case if we can't find one.
jdm commentedon Nov 8, 2014
https://html.spec.whatwg.org/multipage/browsers.html#security-window is relevant. It's tempting to say that we should be able to use the existing Window object, except that it almost certainly exists in a separate JS runtime in the cross-origin case, so we'll need to construct a new one instead.
bzbarsky commentedon Nov 9, 2014
What Gecko does here is return an Xray wrapper wrapper that has a restrictive security policy (with the security policy actually codegenned from IDL annotations).
What the HTML spec has to say on this matter right now is completely useless. What you probably want to look at is Bobby's proposal at https://etherpad.mozilla.org/html5-cross-origin-objects which describes the observable behavior that we and at least some other browser implementors (iirc Google and Microsoft actually responded when we pinged them) agreed was acceptable all around. See https://www.w3.org/Bugs/Public/show_bug.cgi?id=20701 for the spec bug tracking this.
auto merge of #3953 : neojski/servo/implement-HTMLIFrameElement.conte…
auto merge of #3953 : neojski/servo/implement-HTMLIFrameElement.conte…
Auto merge of #6935 - jdm:sslverify, r=Manishearth
jdm commentedon May 12, 2016
Relevant work:
jdm commentedon May 12, 2016
Actually, this work is being tracked in #2382 so no need to keep this open.
servo: Merge #3953 - Add contentDocument support for HTMLIFrameElemen…
servo: Merge #3953 - Add contentDocument support for HTMLIFrameElemen…
servo: Merge #3953 - Add contentDocument support for HTMLIFrameElemen…