Title: [203760] trunk
Revision
203760
Author
[email protected]
Date
2016-07-26 21:12:11 -0700 (Tue, 26 Jul 2016)

Log Message

Second parameter to History.pushState() / replaceState() should be mandatory
https://bugs.webkit.org/show_bug.cgi?id=160230

Reviewed by Sam Weinig.

LayoutTests/imported/w3c:

Rebaseline W3C test now that more checks are passing.

* web-platform-tests/html/dom/interfaces-expected.txt:

Source/WebCore:

Second parameter to History.pushState() / replaceState() should be mandatory:
- https://html.spec.whatwg.org/multipage/browsers.html#history-3

Firefox and Chrome agree with the specification.

No new tests, rebaselined existing test.

* bindings/js/JSHistoryCustom.cpp:
(WebCore::JSHistory::pushState):
(WebCore::JSHistory::replaceState):
* page/History.idl:

LayoutTests:

* fast/history/state-api-parameters.html: Added.
* fast/history/state-api-parameters-expected.txt: Added.
Add layout test coverage.

* fast/history/replacestate-nocrash.html:
* fast/loader/stateobjects/popstate-fires-with-page-cache.html:
Update existing tests to reflect behavior change.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (203759 => 203760)


--- trunk/LayoutTests/ChangeLog	2016-07-27 03:42:30 UTC (rev 203759)
+++ trunk/LayoutTests/ChangeLog	2016-07-27 04:12:11 UTC (rev 203760)
@@ -1,3 +1,18 @@
+2016-07-26  Chris Dumez  <[email protected]>
+
+        Second parameter to History.pushState() / replaceState() should be mandatory
+        https://bugs.webkit.org/show_bug.cgi?id=160230
+
+        Reviewed by Sam Weinig.
+
+        * fast/history/state-api-parameters.html: Added.
+        * fast/history/state-api-parameters-expected.txt: Added.
+        Add layout test coverage.
+
+        * fast/history/replacestate-nocrash.html:
+        * fast/loader/stateobjects/popstate-fires-with-page-cache.html:
+        Update existing tests to reflect behavior change.
+
 2016-07-26  Ryan Haddad  <[email protected]>
 
         Marking inspector/memory/tracking.html as flaky on mac-wk1 debug

Modified: trunk/LayoutTests/fast/history/replacestate-nocrash.html (203759 => 203760)


--- trunk/LayoutTests/fast/history/replacestate-nocrash.html	2016-07-27 03:42:30 UTC (rev 203759)
+++ trunk/LayoutTests/fast/history/replacestate-nocrash.html	2016-07-27 04:12:11 UTC (rev 203760)
@@ -5,8 +5,8 @@
 if (window.testRunner)
     testRunner.dumpAsText();
 
-Object.prototype.__defineSetter__("foo",function(){history.replaceState("")});
-history.replaceState({foo:1,zzz:"a".repeat(1<<22)});
+Object.prototype.__defineSetter__("foo",function(){history.replaceState("", "")});
+history.replaceState({foo:1,zzz:"a".repeat(1<<22)}, "");
 history.state.length;
 </script>
 </html>

Added: trunk/LayoutTests/fast/history/state-api-parameters-expected.txt (0 => 203760)


--- trunk/LayoutTests/fast/history/state-api-parameters-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/history/state-api-parameters-expected.txt	2016-07-27 04:12:11 UTC (rev 203760)
@@ -0,0 +1,13 @@
+Tests that the second parameter to history.replaceState() / pushState() is mandatory.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS history.replaceState() threw exception TypeError: Not enough arguments.
+PASS history.replaceState({}) threw exception TypeError: Not enough arguments.
+PASS history.pushState() threw exception TypeError: Not enough arguments.
+PASS history.pushState({}) threw exception TypeError: Not enough arguments.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/history/state-api-parameters.html (0 => 203760)


--- trunk/LayoutTests/fast/history/state-api-parameters.html	                        (rev 0)
+++ trunk/LayoutTests/fast/history/state-api-parameters.html	2016-07-27 04:12:11 UTC (rev 203760)
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<script>
+description("Tests that the second parameter to history.replaceState() / pushState() is mandatory.");
+
+shouldThrow("history.replaceState()", "'TypeError: Not enough arguments'");
+shouldThrow("history.replaceState({})", "'TypeError: Not enough arguments'");
+shouldThrow("history.pushState()", "'TypeError: Not enough arguments'");
+shouldThrow("history.pushState({})", "'TypeError: Not enough arguments'");
+
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/LayoutTests/fast/loader/stateobjects/popstate-fires-with-page-cache.html (203759 => 203760)


--- trunk/LayoutTests/fast/loader/stateobjects/popstate-fires-with-page-cache.html	2016-07-27 03:42:30 UTC (rev 203759)
+++ trunk/LayoutTests/fast/loader/stateobjects/popstate-fires-with-page-cache.html	2016-07-27 04:12:11 UTC (rev 203760)
@@ -31,7 +31,7 @@
     switch (testWindowLoadFireCount) {
     case 1:
         debug('pushState with new state object for page 1');
-        testWindow.history.pushState('newState');
+        testWindow.history.pushState('newState', '');
         debug('going to page 2');
         // Set the location in a timeout to generate a history entry
         setTimeout(function() {testWindow.location.href = '';}, 0);            
@@ -72,4 +72,4 @@
 var jsTestIsAsync = true;
 </script>
 <script src=""
-</html>
\ No newline at end of file
+</html>

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (203759 => 203760)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2016-07-27 03:42:30 UTC (rev 203759)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2016-07-27 04:12:11 UTC (rev 203760)
@@ -1,5 +1,16 @@
 2016-07-26  Chris Dumez  <[email protected]>
 
+        Second parameter to History.pushState() / replaceState() should be mandatory
+        https://bugs.webkit.org/show_bug.cgi?id=160230
+
+        Reviewed by Sam Weinig.
+
+        Rebaseline W3C test now that more checks are passing.
+
+        * web-platform-tests/html/dom/interfaces-expected.txt:
+
+2016-07-26  Chris Dumez  <[email protected]>
+
         Align Node.isEqualNode() with the specification
         https://bugs.webkit.org/show_bug.cgi?id=160224
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/interfaces-expected.txt (203759 => 203760)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/interfaces-expected.txt	2016-07-27 03:42:30 UTC (rev 203759)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/interfaces-expected.txt	2016-07-27 04:12:11 UTC (rev 203760)
@@ -5550,13 +5550,9 @@
 PASS History interface: window.history must inherit property "back" with the proper type (4) 
 PASS History interface: window.history must inherit property "forward" with the proper type (5) 
 PASS History interface: window.history must inherit property "pushState" with the proper type (6) 
-FAIL History interface: calling pushState(any,DOMString,DOMString) on window.history with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
-            fn.apply(obj, args);
-        }" did not throw
+PASS History interface: calling pushState(any,DOMString,DOMString) on window.history with too few arguments must throw TypeError 
 PASS History interface: window.history must inherit property "replaceState" with the proper type (7) 
-FAIL History interface: calling replaceState(any,DOMString,DOMString) on window.history with too few arguments must throw TypeError assert_throws: Called with 0 arguments function "function () {
-            fn.apply(obj, args);
-        }" did not throw
+PASS History interface: calling replaceState(any,DOMString,DOMString) on window.history with too few arguments must throw TypeError 
 PASS Location interface: existence and properties of interface object 
 PASS Location interface object length 
 PASS Location interface object name 

Modified: trunk/Source/WebCore/ChangeLog (203759 => 203760)


--- trunk/Source/WebCore/ChangeLog	2016-07-27 03:42:30 UTC (rev 203759)
+++ trunk/Source/WebCore/ChangeLog	2016-07-27 04:12:11 UTC (rev 203760)
@@ -1,5 +1,24 @@
 2016-07-26  Chris Dumez  <[email protected]>
 
+        Second parameter to History.pushState() / replaceState() should be mandatory
+        https://bugs.webkit.org/show_bug.cgi?id=160230
+
+        Reviewed by Sam Weinig.
+
+        Second parameter to History.pushState() / replaceState() should be mandatory:
+        - https://html.spec.whatwg.org/multipage/browsers.html#history-3
+
+        Firefox and Chrome agree with the specification.
+
+        No new tests, rebaselined existing test.
+
+        * bindings/js/JSHistoryCustom.cpp:
+        (WebCore::JSHistory::pushState):
+        (WebCore::JSHistory::replaceState):
+        * page/History.idl:
+
+2016-07-26  Chris Dumez  <[email protected]>
+
         Align Node.isEqualNode() with the specification
         https://bugs.webkit.org/show_bug.cgi?id=160224
 

Modified: trunk/Source/WebCore/bindings/js/JSHistoryCustom.cpp (203759 => 203760)


--- trunk/Source/WebCore/bindings/js/JSHistoryCustom.cpp	2016-07-27 03:42:30 UTC (rev 203759)
+++ trunk/Source/WebCore/bindings/js/JSHistoryCustom.cpp	2016-07-27 04:12:11 UTC (rev 203760)
@@ -55,17 +55,22 @@
 
 JSValue JSHistory::pushState(ExecState& state)
 {
-    auto historyState = SerializedScriptValue::create(&state, state.argument(0), 0, 0);
+    auto argCount = state.argumentCount();
+    if (UNLIKELY(argCount < 2))
+        return state.vm().throwException(&state, createNotEnoughArgumentsError(&state));
+
+    auto historyState = SerializedScriptValue::create(&state, state.uncheckedArgument(0), 0, 0);
     if (state.hadException())
         return jsUndefined();
 
-    String title = valueToStringWithUndefinedOrNullCheck(&state, state.argument(1));
+    // FIXME: title should not be nullable.
+    String title = valueToStringWithUndefinedOrNullCheck(&state, state.uncheckedArgument(1));
     if (state.hadException())
         return jsUndefined();
 
     String url;
-    if (state.argumentCount() > 2) {
-        url = "" state.argument(2));
+    if (argCount > 2) {
+        url = "" state.uncheckedArgument(2));
         if (state.hadException())
             return jsUndefined();
     }
@@ -81,17 +86,22 @@
 
 JSValue JSHistory::replaceState(ExecState& state)
 {
-    auto historyState = SerializedScriptValue::create(&state, state.argument(0), 0, 0);
+    auto argCount = state.argumentCount();
+    if (UNLIKELY(argCount < 2))
+        return state.vm().throwException(&state, createNotEnoughArgumentsError(&state));
+
+    auto historyState = SerializedScriptValue::create(&state, state.uncheckedArgument(0), 0, 0);
     if (state.hadException())
         return jsUndefined();
 
-    String title = valueToStringWithUndefinedOrNullCheck(&state, state.argument(1));
+    // FIXME: title should not be nullable.
+    String title = valueToStringWithUndefinedOrNullCheck(&state, state.uncheckedArgument(1));
     if (state.hadException())
         return jsUndefined();
 
     String url;
-    if (state.argumentCount() > 2) {
-        url = "" state.argument(2));
+    if (argCount > 2) {
+        url = "" state.uncheckedArgument(2));
         if (state.hadException())
             return jsUndefined();
     }

Modified: trunk/Source/WebCore/page/History.idl (203759 => 203760)


--- trunk/Source/WebCore/page/History.idl	2016-07-27 03:42:30 UTC (rev 203759)
+++ trunk/Source/WebCore/page/History.idl	2016-07-27 04:12:11 UTC (rev 203760)
@@ -33,6 +33,6 @@
     [CallWith=Document, ForwardDeclareInHeader] void forward();
     [CallWith=Document, ForwardDeclareInHeader] void go(optional long distance = 0);
 
-    [Custom, RaisesException] void pushState(any data, DOMString title, optional DOMString url);
-    [Custom, RaisesException] void replaceState(any data, DOMString title, optional DOMString url);
+    [Custom, RaisesException] void pushState(any data, DOMString title, optional DOMString? url = ""
+    [Custom, RaisesException] void replaceState(any data, DOMString title, optional DOMString? url = ""
 };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to