[Webkit-unassigned] [Bug 76035] Add state attribute to history's dom interface.

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Wed Jan 11 14:53:34 PST 2012


https://bugs.webkit.org/show_bug.cgi?id=76035





--- Comment #12 from Brady Eidson <beidson at apple.com>  2012-01-11 14:53:34 PST ---
(In reply to comment #11)
> In the callback:
> 
>     ASSERT(history.state == stateObject);
> 
> No, because history.state is a new clone, and stateObject an old clone.
> 
>     ASSERT(event.state == stateObject);
> 
> No, same reason (same two clones as the previous assert).
> 
> See "traverse the history", step 10, and notice how that variable is used in steps 11 and 14.
> 
> The others look right.

I see my search for "structured clone" in the spec failed!  I was also kind of surprised that it wasn't a new structured clone.  This makes more sense.  Updated code snippet:

// Create a new object.
var stateObject = new Array;

// Use it as the state object in a replaceState.  This clones the object.
history.replaceState(stateObject, null, null);

// Since the actual history.state is a structured clone, it should not match our original object.
ASSERT(history.state != stateObject);

// Now let's refetch a copy of history.state to store;
stateObject = history.state;

// Our reference and the history.state itself should be the same.  This is now Adam's original assertion.
ASSERT(stateObject == history.state);

// Now let's do a pushstate to add a history entry.
history.pushState(null, null, null);

// Now add a handler for the popstate event.
onpopstate = function(event) {
    // The event's state object and the current state object should match.
    ASSERT(event.state == history.state);
    // Our stored reference to stateObject will not match the current state object, as it is a structured clone of the history item's state object.
    ASSERT(history.state != stateObject);
    // Our stored reference to stateObject will not match the state object in this pop state event, as it is the same as history.state which is a structured clone of the history item's state object.
    ASSERT(event.state != stateObject);

 }

// Now let's go back to our original history entry which has a state object that we've stored a reference to already.
// This will fire our popstate event handler above.
history.back();

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list