[whatwg] Should events be paused on detached iframes?

Ian Hickson ian at hixie.ch
Tue Feb 7 16:16:53 PST 2012


On Tue, 17 Jan 2012, Boris Zbarsky wrote:
> On 1/17/12 6:31 PM, Ian Hickson wrote:
> > > > It should put it up in the context of the top-level browsing context
> > > > of the script that led to that point (the "first script"). This is the
> > > > same as if someone in one tab calls another tab's script and that
> > > > script calls alert().
> > > 
> > > Is that last what browsers actually do?  I'm pretty sure that's not what
> > > Gecko does...
> > 
> > If there's specific features in the spec that are incorrectly specified,
> > I'm happy to address them. Send mail with a test case showing the problem.
> 
> Sure.  Here's a testcase.  You need two files.  test2.html contains:
> 
>   <script>function f() { alert('Called'); }</script>
> 
> test1.html contains:
> 
>   <!DOCTYPE html>
>   <script>
>     var w;
>     function openWindow() {
>       w = window.open("test2.html");
>     }
>     function alertMe() {
>       w.f();
>     }
>   </script>
>   <input type="button"
>          value="Click me to open a new tab then switch back to this
>                 tab and click the other button"
>          onclick="openWindow()">
>   <input type="button" value="Put up an alert"
>          onclick="alertMe()">
> 
> Make sure to not test with a file:// URI to avoid same-origin policy issues.
> Load test1.html, and follow the directions on the first button.
> 
> Results in various browsers:
> 
> Firefox: Clicking the "Put up an alert" button switches to the tab that
> test2.html is loaded in and shows the alert.
> 
> Opera:  Clicking the "Put up an alert" button does nothing visible.  If the
> user ever switches to the test2.html tab, he sees the alert.
> 
> Chrome:  Same as Firefox.
> 
> Safari:  Needs a preference changed to open a tab instead of a window. After
> that, same as Firefox.
> 
> IE9: Same as Opera, but flashes the test2.html tab to indicate that it's got
> an alert associated with it.
> 
> None of them associate the alert with test1.html.

All of the above seem consistent with what the spec requires.

Firefox actually seems to have a slight bug, which is that the event loop 
keeps pumping in the original page, but that seems like a separate issue.

Here's the test case you describe above:

   http://damowmow.com/playground/tests/alert/001.html

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'


More information about the whatwg mailing list