Re: [whatwg] Location object identity and navigation behavior

On Thu, Nov 8, 2012 at 6:09 PM, Adam Barth <> wrote:

> I'm not sure I quite understand what you mean here.  Can you describe
> an experiment that would distinguish these cases?  I looked at [1],
> but it was too complicated for me to understand quickly.
> Consider the following case:
> == Document A ==
> <script>
> = "A1";
> = "A2";
> function f() {
>   var loc = window.location;
>   print(; // print is a magic function that lets me see this value
>   print(;
> }
> </script>
> == Document B ==
> <script>
> = "B1";
> = "B2";
> </script>
> 1) Document A is displayed in browsing context X.
> 2) Browsing context X is navigated and now displays document B.
> 3) Function f is called.
> What values are printed?

Under the proposed behavior, both documents share the same Location object.
So when f() is called for on the navigated-away-from scope, is "B2"
(assuming that print() is magic enough to get around origin restrictions).
"A2" is cleared on navigation per [3] (check out the automated tests in
Patch 7 in the bug), so if B2 was never set, would be undefined.

As for, our new implementation would give "B1", because the
Location object has entirely transplanted into the new Document's scope.
This seems sane to me, but it's certainly up for discussion. Matt, can you
add an expando on Object.prototype in your tests and see what happens?


Received on Friday, 9 November 2012 17:44:33 UTC