WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch.
bug-76035-20120203000344.patch (text/plain), 15.66 KB, created by
Pablo Flouret
on 2012-02-03 00:03:45 PST
(
hide
)
Description:
Patch.
Filename:
MIME Type:
Creator:
Pablo Flouret
Created:
2012-02-03 00:03:45 PST
Size:
15.66 KB
patch
obsolete
>Subversion Revision: 105963 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index e4aeeb233bf4a1425b7af76bebdeea34fd5f1ce5..04e69fd246f781bac59acc2e88b00a5aaa8c57ab 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,34 @@ >+2012-01-31 Pablo Flouret <pablof@motorola.com> >+ >+ Add state attribute to history's dom interface. >+ https://bugs.webkit.org/show_bug.cgi?id=76035 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Tests: fast/loader/stateobjects/state-attribute-object-types.html >+ fast/loader/stateobjects/state-attribute-only-one-deserialization.html >+ >+ * bindings/js/JSHistoryCustom.cpp: >+ (WebCore::JSHistory::state): >+ (WebCore): >+ (WebCore::JSHistory::pushState): >+ (WebCore::JSHistory::replaceState): >+ * bindings/v8/custom/V8HistoryCustom.cpp: >+ (WebCore::V8History::stateAccessorGetter): >+ (WebCore): >+ (WebCore::V8History::pushStateCallback): >+ (WebCore::V8History::replaceStateCallback): >+ * page/History.cpp: >+ (WebCore::History::History): >+ (WebCore::History::state): >+ (WebCore): >+ (WebCore::History::stateInternal): >+ (WebCore::History::stateChanged): >+ * page/History.h: >+ (History): >+ (): >+ * page/History.idl: >+ > 2012-01-26 Pablo Flouret <pablof@motorola.com> > > Fix bad code generated by the JSC idl code generator for [CachedAttribute] attributes >diff --git a/Source/WebCore/bindings/js/JSHistoryCustom.cpp b/Source/WebCore/bindings/js/JSHistoryCustom.cpp >index 72ea5424c7c12f3a672bc7d739e11dedfb4818c7..e11b9571dbd6bcf193e8fa3f88eb773f5d36dc0d 100644 >--- a/Source/WebCore/bindings/js/JSHistoryCustom.cpp >+++ b/Source/WebCore/bindings/js/JSHistoryCustom.cpp >@@ -164,6 +164,20 @@ void JSHistory::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyN > Base::getOwnPropertyNames(thisObject, exec, propertyNames, mode); > } > >+JSValue JSHistory::state(ExecState *exec) const >+{ >+ History* history = static_cast<History*>(impl()); >+ >+ JSValue cachedValue = m_state.get(); >+ if (!cachedValue.isEmpty() && !history->stateChanged()) >+ return cachedValue; >+ >+ SerializedScriptValue* serialized = history->state(); >+ JSValue result = serialized ? serialized->deserialize(exec, globalObject(), 0) : jsNull(); >+ const_cast<JSHistory*>(this)->m_state.set(exec->globalData(), this, result); >+ return result; >+} >+ > JSValue JSHistory::pushState(ExecState* exec) > { > RefPtr<SerializedScriptValue> historyState = SerializedScriptValue::create(exec, exec->argument(0), 0); >@@ -185,6 +199,8 @@ JSValue JSHistory::pushState(ExecState* exec) > impl()->stateObjectAdded(historyState.release(), title, url, History::StateObjectPush, ec); > setDOMException(exec, ec); > >+ m_state.clear(); >+ > return jsUndefined(); > } > >@@ -209,6 +225,8 @@ JSValue JSHistory::replaceState(ExecState* exec) > impl()->stateObjectAdded(historyState.release(), title, url, History::StateObjectReplace, ec); > setDOMException(exec, ec); > >+ m_state.clear(); >+ > return jsUndefined(); > } > >diff --git a/Source/WebCore/bindings/v8/custom/V8HistoryCustom.cpp b/Source/WebCore/bindings/v8/custom/V8HistoryCustom.cpp >index 89561090ca149dbd1ef7036a91cd3a9a7efba68b..a1bd76b2abe4063eea7c65cc77e6a7d093239fbc 100644 >--- a/Source/WebCore/bindings/v8/custom/V8HistoryCustom.cpp >+++ b/Source/WebCore/bindings/v8/custom/V8HistoryCustom.cpp >@@ -41,6 +41,24 @@ > > namespace WebCore { > >+v8::Handle<v8::Value> V8History::stateAccessorGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) >+{ >+ INC_STATS("DOM.History.state"); >+ History* history = V8History::toNative(info.Holder()); >+ >+ v8::Handle<v8::String> propertyName = v8::String::NewSymbol("state"); >+ v8::Handle<v8::Value> value = info.Holder()->GetHiddenValue(propertyName); >+ >+ if (!value.IsEmpty() && !history->stateChanged()) >+ return value; >+ >+ SerializedScriptValue* serialized = history->state(); >+ value = serialized ? serialized->deserialize() : v8::Handle<v8::Value>(v8::Null()); >+ info.Holder()->SetHiddenValue(propertyName, value); >+ >+ return value; >+} >+ > v8::Handle<v8::Value> V8History::pushStateCallback(const v8::Arguments& args) > { > bool didThrow = false; >@@ -62,6 +80,7 @@ v8::Handle<v8::Value> V8History::pushStateCallback(const v8::Arguments& args) > ExceptionCode ec = 0; > History* history = V8History::toNative(args.Holder()); > history->stateObjectAdded(historyState.release(), title, url, History::StateObjectPush, ec); >+ args.Holder()->DeleteHiddenValue(v8::String::NewSymbol("state")); > return throwError(ec); > } > >@@ -86,6 +105,7 @@ v8::Handle<v8::Value> V8History::replaceStateCallback(const v8::Arguments& args) > ExceptionCode ec = 0; > History* history = V8History::toNative(args.Holder()); > history->stateObjectAdded(historyState.release(), title, url, History::StateObjectReplace, ec); >+ args.Holder()->DeleteHiddenValue(v8::String::NewSymbol("state")); > return throwError(ec); > } > >diff --git a/Source/WebCore/page/History.cpp b/Source/WebCore/page/History.cpp >index 1f5a39f287584f7c2748b33e1099e664d192ae68..a1f9a05f661c13ff2ad6d629ea87ae74e85a2afc 100644 >--- a/Source/WebCore/page/History.cpp >+++ b/Source/WebCore/page/History.cpp >@@ -42,6 +42,7 @@ namespace WebCore { > > History::History(Frame* frame) > : DOMWindowProperty(frame) >+ , m_lastStateObjectRequested(0) > { > } > >@@ -54,6 +55,28 @@ unsigned History::length() const > return m_frame->page()->backForward()->count(); > } > >+SerializedScriptValue* History::state() >+{ >+ m_lastStateObjectRequested = stateInternal(); >+ return m_lastStateObjectRequested; >+} >+ >+SerializedScriptValue* History::stateInternal() const >+{ >+ if (!m_frame) >+ return 0; >+ >+ if (HistoryItem* historyItem = m_frame->loader()->history()->currentItem()) >+ return historyItem->stateObject(); >+ >+ return 0; >+} >+ >+bool History::stateChanged() const >+{ >+ return m_lastStateObjectRequested != stateInternal(); >+} >+ > void History::back() > { > go(-1); >diff --git a/Source/WebCore/page/History.h b/Source/WebCore/page/History.h >index bd50fccd2b861d9e6418e974f42dfb2b2b5f91ce..bd6f6aa21315fa55feedc4527d0d32cb390c2e58 100644 >--- a/Source/WebCore/page/History.h >+++ b/Source/WebCore/page/History.h >@@ -44,6 +44,8 @@ public: > static PassRefPtr<History> create(Frame* frame) { return adoptRef(new History(frame)); } > > unsigned length() const; >+ SerializedScriptValue* state(); >+ bool stateChanged() const; > void back(); > void forward(); > void go(int distance); >@@ -62,6 +64,10 @@ private: > explicit History(Frame*); > > KURL urlForState(const String& url); >+ >+ SerializedScriptValue* stateInternal() const; >+ >+ SerializedScriptValue* m_lastStateObjectRequested; > }; > > } // namespace WebCore >diff --git a/Source/WebCore/page/History.idl b/Source/WebCore/page/History.idl >index ff3701ed276d4f5698da6a0530e066380a33b1c1..6779458eefa95d1668812d5ae7ce444bad1d91db 100644 >--- a/Source/WebCore/page/History.idl >+++ b/Source/WebCore/page/History.idl >@@ -37,6 +37,7 @@ module window { > OmitConstructor > ] History { > readonly attribute unsigned long length; >+ readonly attribute [CachedAttribute, Custom] SerializedScriptValue state; > > [DoNotCheckDomainSecurity, CallWith=ScriptExecutionContext] void back(); > [DoNotCheckDomainSecurity, CallWith=ScriptExecutionContext] void forward(); >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 5ee6b5c82adbaa399e710575f63ecab445b79fe3..39a78bc1421cc3016fd525098f4f468cef5600e8 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,15 @@ >+2012-01-31 Pablo Flouret <pablof@motorola.com> >+ >+ Add state attribute to history's dom interface. >+ https://bugs.webkit.org/show_bug.cgi?id=76035 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ * fast/loader/stateobjects/state-attribute-object-types-expected.txt: Added. >+ * fast/loader/stateobjects/state-attribute-object-types.html: Added. >+ * fast/loader/stateobjects/state-attribute-only-one-deserialization-expected.txt: Added. >+ * fast/loader/stateobjects/state-attribute-only-one-deserialization.html: Added. >+ > 2012-01-25 Levi Weintraub <leviw@chromium.org> > > Layout Test fast/js/dfg-uint32array-overflow-values.html is slow on Chromium Debug bots >diff --git a/LayoutTests/fast/loader/stateobjects/state-attribute-object-types-expected.txt b/LayoutTests/fast/loader/stateobjects/state-attribute-object-types-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..e042169d360de6832296235067149c81055f0ef9 >--- /dev/null >+++ b/LayoutTests/fast/loader/stateobjects/state-attribute-object-types-expected.txt >@@ -0,0 +1,25 @@ >+This test calls pushState with state objects of all the different object types supported by the HTML5 "internal structured cloning algorithm" and makes sure the state attribute returns the expected objects. >+ >+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". >+ >+ >+PASS history.state is defined. >+ >+history.state should initially be null. >+PASS history.state is null >+ >+PASS history.state is undefined. >+PASS history.state is null >+PASS history.state is false >+PASS history.state is true >+PASS history.state is 42 >+PASS history.state is "String" >+PASS history.state == 'Wed Dec 31 1969 16:00:00 GMT-0800 (PST)' is true >+PASS history.state == '/foo/gi' is true >+PASS history.state == '' is true >+PASS history.state == '[object Object]' is true >+PASS history.state == '[object ImageData]' is true >+PASS successfullyParsed is true >+ >+TEST COMPLETE >+ >diff --git a/LayoutTests/fast/loader/stateobjects/state-attribute-object-types.html b/LayoutTests/fast/loader/stateobjects/state-attribute-object-types.html >new file mode 100644 >index 0000000000000000000000000000000000000000..16b9abb2ed6158ad0b67a5a23177851e67c47b29 >--- /dev/null >+++ b/LayoutTests/fast/loader/stateobjects/state-attribute-object-types.html >@@ -0,0 +1,44 @@ >+<!DOCTYPE html> >+<html> >+<head> >+ <script src="../../js/resources/js-test-pre.js"></script> >+</head/> >+<body> >+<script> >+ description('This test calls pushState with state objects of all the different object types supported by the HTML5 "internal structured cloning algorithm" and makes sure the state attribute returns the expected objects.'); >+ >+ if (window.layoutTestController) >+ layoutTestController.clearBackForwardList(); >+ >+ shouldBeDefined("history.state"); >+ debug("\nhistory.state should initially be null."); >+ shouldBeNull("history.state"); >+ debug(""); >+ >+ history.pushState(undefined, "undefined entry"); >+ shouldBeUndefined("history.state"); >+ history.pushState(null, "null entry"); >+ shouldBeNull("history.state"); >+ history.pushState(false, "false entry"); >+ shouldBeFalse("history.state"); >+ history.pushState(true, "true entry"); >+ shouldBeTrue("history.state"); >+ history.pushState(42, "Number entry"); >+ shouldBe("history.state", "42"); >+ history.pushState("String", "String entry"); >+ shouldBeEqualToString("history.state", "String"); >+ history.pushState(new Date(0), "Date entry"); >+ shouldEvaluateTo("history.state", new Date(0)); >+ history.pushState(new RegExp("foo", "gi"), "RegExp entry"); >+ shouldEvaluateTo("history.state", new RegExp("foo", "gi")); >+ history.pushState(new Array, "Array entry"); >+ shouldEvaluateTo("history.state", new Array); >+ history.pushState(new Object, "Object entry"); >+ shouldEvaluateTo("history.state", new Object); >+ history.pushState(document.createElement("canvas").getContext("2d").createImageData(10,10), "ImageData entry"); >+ shouldEvaluateTo("history.state", document.createElement("canvas").getContext("2d").createImageData(10,10)); >+</script> >+<script src="../../js/resources/js-test-post.js"></script> >+</body> >+</html> >+ >diff --git a/LayoutTests/fast/loader/stateobjects/state-attribute-only-one-deserialization-expected.txt b/LayoutTests/fast/loader/stateobjects/state-attribute-only-one-deserialization-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..e3d0117f99dd8faba6bd5244fd745c74da69dfc0 >--- /dev/null >+++ b/LayoutTests/fast/loader/stateobjects/state-attribute-only-one-deserialization-expected.txt >@@ -0,0 +1,19 @@ >+Make sure the same deserialization of the state object is used every time (both in the history object and popstate events). >+ >+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". >+ >+ >+PASS history.state is defined. >+PASS history.state === history.state is true >+PASS history.state !== stateObject is true >+PASS history.state === stateObject is true >+ >+Inside popstate event >+ >+PASS history.state !== stateObject is true >+PASS popStateEvent.state !== stateObject is true >+FAIL popStateEvent.state === history.state should be true. Was false. >+PASS successfullyParsed is true >+ >+TEST COMPLETE >+ >diff --git a/LayoutTests/fast/loader/stateobjects/state-attribute-only-one-deserialization.html b/LayoutTests/fast/loader/stateobjects/state-attribute-only-one-deserialization.html >new file mode 100644 >index 0000000000000000000000000000000000000000..083721d3834896002b6bf5b23591102b1c3feadc >--- /dev/null >+++ b/LayoutTests/fast/loader/stateobjects/state-attribute-only-one-deserialization.html >@@ -0,0 +1,61 @@ >+<!DOCTYPE html> >+<html> >+<head> >+ <script src="../../js/resources/js-test-pre.js"></script> >+</head/> >+<body> >+<script> >+ description("Make sure the same deserialization of the state object is used every time (both in the history object and popstate events)."); >+ >+ window.jsTestIsAsync = true; >+ if (window.layoutTestController) { >+ layoutTestController.clearBackForwardList(); >+ layoutTestController.waitUntilDone(); >+ } >+ >+ shouldBeDefined("history.state"); >+ >+ // Create a new object. >+ var stateObject = ["a"]; >+ >+ // Use it as the state object in a replaceState. This clones the object. >+ history.replaceState(stateObject, null, null); >+ >+ shouldBeTrue("history.state === history.state"); >+ >+ // Since the actual history.state is a structured clone, it should not match our original object. >+ shouldBeTrue("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. >+ shouldBeTrue("history.state === stateObject"); >+ >+ // Now let's do a pushstate to add a history entry. >+ history.pushState(null, null, null); >+ >+ // Now add a handler for the popstate event. >+ var popStateEvent; >+ window.onpopstate = function(e) { >+ debug("\nInside popstate event\n"); >+ popStateEvent = e; >+ // 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. >+ shouldBeTrue("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. >+ shouldBeTrue("popStateEvent.state !== stateObject"); >+ // The event's state object and the current state object should match. >+ shouldBeTrue("popStateEvent.state === history.state"); // This fails for now, needs to be fixed. >+ >+ var s = document.createElement("script"); >+ s.src = "../../js/resources/js-test-post.js"; >+ document.body.appendChild(s); >+ setTimeout(finishJSTest, 0); >+ } >+ >+ // 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(); >+</script> >+</body> >+</html>
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 76035
:
121987
|
122471
|
122518
|
122586
|
122857
|
122860
|
123150
|
124811
|
124856
|
125274
|
126022