W3C home > Mailing lists > Public > www-dom@w3.org > October to December 2012

Re: [dom] Need to describe the interaction of adoptNode with prototype chains

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Mon, 24 Dec 2012 14:53:19 -0800
Message-ID: <50D8DCDF.8080909@mit.edu>
To: David Bruant <bruant.d@gmail.com>
CC: Anne van Kesteren <annevk@annevk.nl>, www-dom@w3.org, Cameron McCormack <cam@mcc.id.au>, Bobby Holley <bholley@mozilla.com>
On 12/24/12 2:36 PM, David Bruant wrote:
> Only script that existed before the document.open can observe this.

Yes.  Like for example the script that called open() and then continues 

> Scripts inside the new document think they are in a fresh browsing
> context if I understand correctly.

No.  There is only one browsing context.  Browsing contexts don't even 
change across navigations.

Scripts created after the open() will see a new ES global.  Scripts 
created before the open() keep seeing the old one as their global.

> From the new document point of view,
> it "feels" like a navigation just occurred. Only the script from the
> previous context can tell the difference.

With s/context/global/ yes.  Or of course script from outside the 
navigation context altogether.

> The current spec and implementations think of document.open as:
> * before the call, you're in a browsing context
> * after, you're in the same browsing context, but everything except the
> document identity has changed


> What about thinking of it the following way:
> * before the call, you're in a browsing context
> * after the call, you're in a new browsing context (navigation)

Navigation doesn't change the browsing context.  It creates a new Window 
(which is the ES global) and new Document.

> and some script from the previous browsing context has survived and runs *in the
> new context* (the context change happens during the document.open call)

No, the script that called open() needs to keep running against the old 
global.  Not doing that breaks things, last I checked.

Consider this testcase:

     var x = 1;
     window.onload = function() {

> I feel this script context change is "light-weight" compared to the
> current solution.

I'm not sure how it is; it's the same amount of specification work....

> I don't know if such a script context change can be implemented in
> JavaScript.

Even if it could be, I think it would break my testcase above, no?

Received on Monday, 24 December 2012 22:53:52 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 22:37:01 UTC