[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 12:53:08 PST 2012


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





--- Comment #5 from Brady Eidson <beidson at apple.com>  2012-01-11 12:53:07 PST ---
(In reply to comment #2)
> (From update of attachment 121987 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=121987&action=review
> 
> Thanks for working on this bug.  One issue below:
> 
> > Source/WebCore/bindings/js/JSHistoryCustom.cpp:170
> > +    History* history = static_cast<History*>(impl());
> > +    return history->stateObject()->deserialize(exec, globalObject(), 0);
> 
> I think this isn't quite right.  Every time we call this getter, we're going to deserialize the state object again.  That means
> 
> history.state !== history.state
> 
> which doesn't seem to match the spec.  If that's what other browsers do, then we can change the spec, but it's more likely that we should cache the result of deserializing the SerializedScriptValue and aways return the same value.
> 

I think it's even more complicated than this.  In addition to the requirement that "history.state == history.state" I think the identity has to match with the object in the pop state event.  I think the following JS code is valid:

// 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;

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

// Now let's go back to our original history entry which has a state object that we've stored a reference to already.
history.back();

// Now a handler for the popstate event.
onpopstate = function(event) {
    // Our stored reference to stateObject should match the current state object.
    ASSERT(history.state == stateObject);
    // AND our stored reference to stateObject should match the state object in this popstate event.
    ASSERT(event.state == stateObject);
    // For good measure, the event's state object and the current state object should also both match.
    ASSERT(event.state == history.state);
 }

-- 
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