WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Fixed tests
bug-76035-20120208001705.patch (text/plain), 16.34 KB, created by
Pablo Flouret
on 2012-02-08 00:17:07 PST
(
hide
)
Description:
Fixed tests
Filename:
MIME Type:
Creator:
Pablo Flouret
Created:
2012-02-08 00:17:07 PST
Size:
16.34 KB
patch
obsolete
>Subversion Revision: 107023 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 6711b57652567068b081d975a64a7540bf4cf4cb..2cbcf0b78936693acb8be9b85913f1f72671caaf 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,33 @@ >+2012-02-07 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-02-07 Chris Palmer <palmer@google.com> > > Resolve crash in FrameLoader::checkTimerFired. >diff --git a/Source/WebCore/bindings/js/JSHistoryCustom.cpp b/Source/WebCore/bindings/js/JSHistoryCustom.cpp >index 1aedb86f99c70e7cf7df84fe93a231960201a5ff..480658b51182c2ece29ed57ddeca35b26c29e081 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 e5e7d684710cff385e15cb8285e387a6e0e0e7e0..44787bf90c55b22e6b0909c222f09215e77a2d93 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 98e02fed8f71c6643035dd5e6e7744326763afa4..7c6c60644000ffc4a98cee17dcf2e2c932727154 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,16 @@ >+2012-02-07 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/dom/Window/window-appendages-cleared-expected.txt: >+ * 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-02-07 Chris Palmer <palmer@google.com> > > Resolve crash in FrameLoader::checkTimerFired. >diff --git a/LayoutTests/fast/dom/Window/window-appendages-cleared-expected.txt b/LayoutTests/fast/dom/Window/window-appendages-cleared-expected.txt >index 8506efa0ca2e1d08872b9723ebcda40eb3f67528..7b7614c3ef3e460e383e1ebd112bc40b195cfa16 100644 >--- a/LayoutTests/fast/dom/Window/window-appendages-cleared-expected.txt >+++ b/LayoutTests/fast/dom/Window/window-appendages-cleared-expected.txt >@@ -4,6 +4,7 @@ PASS history.go == "LEFTOVER" is false > PASS history.length == "LEFTOVER" is false > PASS history.pushState == "LEFTOVER" is false > PASS history.replaceState == "LEFTOVER" is false >+PASS history.state == "LEFTOVER" is false > PASS location.assign == "LEFTOVER" is false > PASS location.hash == "LEFTOVER" is false > PASS location.host == "LEFTOVER" is false >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..225306b0987685d7bed0051b6697d0ab1cc6c0d2 >--- /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 is +(new Date(0)) >+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..b089b22fe970319e6e37d845554df26f0bf6cfe8 >--- /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"); >+ shouldBe("+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