Title: [196797] trunk
Revision
196797
Author
[email protected]
Date
2016-02-18 21:17:32 -0800 (Thu, 18 Feb 2016)

Log Message

window.history / window.navigator should not be replaceable
https://bugs.webkit.org/show_bug.cgi?id=154412

Reviewed by Ryosuke Niwa.

LayoutTests/imported/w3c:

Rebaseline now that more checks are passing.

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

Source/WebCore:

window.history / window.navigator should not be replaceable as per
the latest HTML specification:
https://html.spec.whatwg.org/multipage/browsers.html#the-window-object

Firefox and Chrome already match the specification. This patch aligns
our behavior.

No new tests, already covered by existing tests.

* page/DOMWindow.idl:

LayoutTests:

Update / rebaseline existing tests now that window.history and
window.navigator are no longer replaceable.

* fast/dom/Window/get-set-properties-expected.txt:
* fast/dom/Window/get-set-properties.html:
* fast/dom/Window/window-property-shadowing-expected.txt:
* fast/dom/Window/window-property-shadowing.html:
* http/tests/history/cross-origin-replace-history-object-child-expected.txt:
* http/tests/history/resources/cross-origin-replaces-history-object-child-iframe.html:
* js/dom/var-declarations-shadowing-expected.txt:
* js/dom/var-declarations-shadowing.html:
* js/getOwnPropertyDescriptor-window-attributes-expected.txt:
* js/getOwnPropertyDescriptor-window-attributes.html:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (196796 => 196797)


--- trunk/LayoutTests/ChangeLog	2016-02-19 05:12:02 UTC (rev 196796)
+++ trunk/LayoutTests/ChangeLog	2016-02-19 05:17:32 UTC (rev 196797)
@@ -1,3 +1,24 @@
+2016-02-18  Chris Dumez  <[email protected]>
+
+        window.history / window.navigator should not be replaceable
+        https://bugs.webkit.org/show_bug.cgi?id=154412
+
+        Reviewed by Ryosuke Niwa.
+
+        Update / rebaseline existing tests now that window.history and
+        window.navigator are no longer replaceable.
+
+        * fast/dom/Window/get-set-properties-expected.txt:
+        * fast/dom/Window/get-set-properties.html:
+        * fast/dom/Window/window-property-shadowing-expected.txt:
+        * fast/dom/Window/window-property-shadowing.html:
+        * http/tests/history/cross-origin-replace-history-object-child-expected.txt:
+        * http/tests/history/resources/cross-origin-replaces-history-object-child-iframe.html:
+        * js/dom/var-declarations-shadowing-expected.txt:
+        * js/dom/var-declarations-shadowing.html:
+        * js/getOwnPropertyDescriptor-window-attributes-expected.txt:
+        * js/getOwnPropertyDescriptor-window-attributes.html:
+
 2016-02-18  Simon Fraser  <[email protected]>
 
         Wheel event callback removing the window causes crash in WebCore.

Modified: trunk/LayoutTests/fast/dom/Window/get-set-properties-expected.txt (196796 => 196797)


--- trunk/LayoutTests/fast/dom/Window/get-set-properties-expected.txt	2016-02-19 05:12:02 UTC (rev 196796)
+++ trunk/LayoutTests/fast/dom/Window/get-set-properties-expected.txt	2016-02-19 05:17:32 UTC (rev 196797)
@@ -207,8 +207,6 @@
 PASS: canSet('event') should be 'true' and is.
 PASS: canGet('frames') should be 'true' and is.
 PASS: canSet('frames') should be 'true' and is.
-PASS: canGet('history') should be 'true' and is.
-PASS: canSet('history') should be 'true' and is.
 PASS: canGet('innerHeight') should be 'true' and is.
 PASS: canSet('innerHeight') should be 'true' and is.
 PASS: canGet('innerWidth') should be 'true' and is.
@@ -219,8 +217,6 @@
 PASS: canSet('locationbar') should be 'true' and is.
 PASS: canGet('menubar') should be 'true' and is.
 PASS: canSet('menubar') should be 'true' and is.
-PASS: canGet('navigator') should be 'true' and is.
-PASS: canSet('navigator') should be 'true' and is.
 PASS: canGet('offscreenBuffering') should be 'true' and is.
 PASS: canSet('offscreenBuffering') should be 'true' and is.
 PASS: canGet('opener') should be 'true' and is.
@@ -260,6 +256,10 @@
 PASS: canSet('closed') should be 'false' and is.
 PASS: canGet('document') should be 'true' and is.
 PASS: canSet('document') should be 'false' and is.
+PASS: canGet('history') should be 'true' and is.
+PASS: canSet('history') should be 'false' and is.
+PASS: canGet('navigator') should be 'true' and is.
+PASS: canSet('navigator') should be 'false' and is.
 PASS: canGet('pageXOffset') should be 'true' and is.
 PASS: canSet('pageXOffset') should be 'false' and is.
 PASS: canGet('pageYOffset') should be 'true' and is.

Modified: trunk/LayoutTests/fast/dom/Window/get-set-properties.html (196796 => 196797)


--- trunk/LayoutTests/fast/dom/Window/get-set-properties.html	2016-02-19 05:12:02 UTC (rev 196796)
+++ trunk/LayoutTests/fast/dom/Window/get-set-properties.html	2016-02-19 05:17:32 UTC (rev 196797)
@@ -171,13 +171,11 @@
     "devicePixelRatio", 
     "event", 
     "frames",
-    "history",
     "innerHeight", 
     "innerWidth", 
     "length",
     "locationbar", 
     "menubar", 
-    "navigator", 
     "offscreenBuffering", 
     "opener",
     "outerHeight", 
@@ -199,6 +197,8 @@
 var windowReadOnlyProperties = [
     "closed",
     "document",
+    "history",
+    "navigator",
     "pageXOffset",
     "pageYOffset",
     "window",

Modified: trunk/LayoutTests/fast/dom/Window/window-property-shadowing-expected.txt (196796 => 196797)


--- trunk/LayoutTests/fast/dom/Window/window-property-shadowing-expected.txt	2016-02-19 05:12:02 UTC (rev 196796)
+++ trunk/LayoutTests/fast/dom/Window/window-property-shadowing-expected.txt	2016-02-19 05:17:32 UTC (rev 196797)
@@ -13,7 +13,7 @@
 PASS: innerWidth successfully shadowed
 PASS: length successfully shadowed
 PASS: name successfully shadowed
-PASS: navigator successfully shadowed
+PASS: navigator was not shadowed
 PASS: clientInformation successfully shadowed
 PASS: screen successfully shadowed
 PASS: offscreenBuffering successfully shadowed
@@ -28,7 +28,7 @@
 PASS: scrollX successfully shadowed
 PASS: scrollY successfully shadowed
 PASS: self successfully shadowed
-PASS: history successfully shadowed
+PASS: history was not shadowed
 PASS: getSelection successfully shadowed
 PASS: getComputedStyle successfully shadowed
 PASS: getMatchedCSSRules successfully shadowed

Modified: trunk/LayoutTests/fast/dom/Window/window-property-shadowing.html (196796 => 196797)


--- trunk/LayoutTests/fast/dom/Window/window-property-shadowing.html	2016-02-19 05:12:02 UTC (rev 196796)
+++ trunk/LayoutTests/fast/dom/Window/window-property-shadowing.html	2016-02-19 05:17:32 UTC (rev 196797)
@@ -46,7 +46,7 @@
         var name = 1;
         log(name == 1 ? "PASS: name successfully shadowed" : "FAIL: name was not shadowed");
         var navigator = 1;
-        log(navigator == 1 ? "PASS: navigator successfully shadowed" : "FAIL: navigator was not shadowed");
+        log(navigator == 1 ? "FAIL: navigator successfully shadowed" : "PASS: navigator was not shadowed");
         var clientInformation = 1;
         log(clientInformation == 1 ? "PASS: clientInformation successfully shadowed" : "FAIL: clientInformation was not shadowed");
         var screen = 1;
@@ -76,7 +76,7 @@
         var self = 1;
         log(self == 1 ? "PASS: self successfully shadowed" : "FAIL: self was not shadowed");
         var history = 1;
-        log(history == 1 ? "PASS: history successfully shadowed" : "FAIL: history was not shadowed");
+        log(history == 1 ? "FAIL: history successfully shadowed" : "PASS: history was not shadowed");
 
         // Window functions
         var getSelection = 1;

Modified: trunk/LayoutTests/http/tests/history/cross-origin-replace-history-object-child-expected.txt (196796 => 196797)


--- trunk/LayoutTests/http/tests/history/cross-origin-replace-history-object-child-expected.txt	2016-02-19 05:12:02 UTC (rev 196796)
+++ trunk/LayoutTests/http/tests/history/cross-origin-replace-history-object-child-expected.txt	2016-02-19 05:17:32 UTC (rev 196797)
@@ -1,7 +1,7 @@
 CONSOLE MESSAGE: line 30: Blocked a frame with origin "http://127.0.0.1:8000" from accessing a frame with origin "http://localhost:8000". Protocols, domains, and ports must match.
 ALERT: Child window's history object before attempt to clear: undefined
 ALERT: About to shadow child window's history object: [object History]
-ALERT: Shadowed child window's history object: 
+ALERT: PASS: Could not shadow child window's history object: [object History]
 CONSOLE MESSAGE: line 18: Blocked a frame with origin "http://127.0.0.1:8000" from accessing a frame with origin "http://localhost:8000". Protocols, domains, and ports must match.
 ALERT: Child window's history object after attempt to clear: undefined
 

Modified: trunk/LayoutTests/http/tests/history/resources/cross-origin-replaces-history-object-child-iframe.html (196796 => 196797)


--- trunk/LayoutTests/http/tests/history/resources/cross-origin-replaces-history-object-child-iframe.html	2016-02-19 05:12:02 UTC (rev 196796)
+++ trunk/LayoutTests/http/tests/history/resources/cross-origin-replaces-history-object-child-iframe.html	2016-02-19 05:17:32 UTC (rev 196797)
@@ -16,7 +16,10 @@
 {
     alert("About to shadow child window's history object: " + window.history);
     window.history = "";
-    alert("Shadowed child window's history object: " + window.history);
+    if (window.history === "")
+        alert("FAIL: Shadowed child window's history object: " + window.history);
+    else
+        alert("PASS: Could not shadow child window's history object: " + window.history);
     parent.window.postMessage("done", "*");
 }
 

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (196796 => 196797)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2016-02-19 05:12:02 UTC (rev 196796)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2016-02-19 05:17:32 UTC (rev 196797)
@@ -1,5 +1,16 @@
 2016-02-18  Chris Dumez  <[email protected]>
 
+        window.history / window.navigator should not be replaceable
+        https://bugs.webkit.org/show_bug.cgi?id=154412
+
+        Reviewed by Ryosuke Niwa.
+
+        Rebaseline now that more checks are passing.
+
+        * web-platform-tests/html/dom/interfaces-expected.txt:
+
+2016-02-18  Chris Dumez  <[email protected]>
+
         HTMLTableHeaderCellElement.scope should only return known values
         https://bugs.webkit.org/show_bug.cgi?id=154423
         <rdar://problem/24731018>

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


--- trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/interfaces-expected.txt	2016-02-19 05:12:02 UTC (rev 196796)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/html/dom/interfaces-expected.txt	2016-02-19 05:17:32 UTC (rev 196797)
@@ -3814,9 +3814,7 @@
 PASS Window interface: existence and properties of interface prototype object's "constructor" property 
 PASS Window interface: attribute self 
 PASS Window interface: attribute name 
-FAIL Window interface: attribute history assert_equals: setter must be undefined for readonly attributes expected (undefined) undefined but got (function) function "function history() {
-    [native code]
-}"
+PASS Window interface: attribute history 
 PASS Window interface: attribute locationbar 
 PASS Window interface: attribute menubar 
 PASS Window interface: attribute personalbar 
@@ -3835,9 +3833,7 @@
 PASS Window interface: attribute parent 
 PASS Window interface: attribute frameElement 
 FAIL Window interface: operation open(DOMString,DOMString,DOMString,boolean) assert_equals: property has wrong .length expected 0 but got 2
-FAIL Window interface: attribute navigator assert_equals: setter must be undefined for readonly attributes expected (undefined) undefined but got (function) function "function navigator() {
-    [native code]
-}"
+PASS Window interface: attribute navigator 
 FAIL Window interface: attribute external assert_own_property: The global object must have a property "external" expected property "external" missing
 PASS Window interface: attribute applicationCache 
 PASS Window interface: operation alert() 

Modified: trunk/LayoutTests/js/dom/var-declarations-shadowing-expected.txt (196796 => 196797)


--- trunk/LayoutTests/js/dom/var-declarations-shadowing-expected.txt	2016-02-19 05:12:02 UTC (rev 196796)
+++ trunk/LayoutTests/js/dom/var-declarations-shadowing-expected.txt	2016-02-19 05:17:32 UTC (rev 196797)
@@ -68,8 +68,8 @@
 PASS: eval('devicePixelRatio == marker') should be true and is.
 PASS: devicePixelRatio == marker should be true and is.
 PASS: eval('devicePixelRatio == marker') should be true and is.
-PASS: navigator == marker should be true and is.
-PASS: eval('navigator == marker') should be true and is.
+PASS: navigator == marker should be false and is.
+PASS: eval('navigator == marker') should be false and is.
 PASS: clientInformation == marker should be true and is.
 PASS: eval('clientInformation == marker') should be true and is.
 PASS: status == marker should be true and is.
@@ -80,8 +80,8 @@
 PASS: eval('defaultstatus == marker') should be true and is.
 PASS: screen == marker should be true and is.
 PASS: eval('screen == marker') should be true and is.
-PASS: history == marker should be true and is.
-PASS: eval('history == marker') should be true and is.
+PASS: history == marker should be false and is.
+PASS: eval('history == marker') should be false and is.
 -----
 PASS: frameElement == marker should be false and is.
 PASS: eval('frameElement == marker') should be false and is.

Modified: trunk/LayoutTests/js/dom/var-declarations-shadowing.html (196796 => 196797)


--- trunk/LayoutTests/js/dom/var-declarations-shadowing.html	2016-02-19 05:12:02 UTC (rev 196796)
+++ trunk/LayoutTests/js/dom/var-declarations-shadowing.html	2016-02-19 05:17:32 UTC (rev 196797)
@@ -220,8 +220,8 @@
 try {
     eval("var navigator = marker");
 } catch(e) { }
-shouldBe(navigator == marker, "navigator == marker", true);
-shouldBe(eval('navigator == marker'), "eval('navigator == marker')", true);
+shouldBe(navigator == marker, "navigator == marker", false);
+shouldBe(eval('navigator == marker'), "eval('navigator == marker')", false);
 
 try {
     eval("var clientInformation = marker");
@@ -256,8 +256,8 @@
 try {
     eval("var history = marker");
 } catch(e) { }
-shouldBe(history == marker, "history == marker", true);
-shouldBe(eval('history == marker'), "eval('history == marker')", true);
+shouldBe(history == marker, "history == marker", false);
+shouldBe(eval('history == marker'), "eval('history == marker')", false);
 
 log("-----");
 

Modified: trunk/LayoutTests/js/getOwnPropertyDescriptor-window-attributes-expected.txt (196796 => 196797)


--- trunk/LayoutTests/js/getOwnPropertyDescriptor-window-attributes-expected.txt	2016-02-19 05:12:02 UTC (rev 196796)
+++ trunk/LayoutTests/js/getOwnPropertyDescriptor-window-attributes-expected.txt	2016-02-19 05:17:32 UTC (rev 196797)
@@ -14,7 +14,7 @@
 
 * Window.navigator
 PASS descriptor.get is an instance of Function
-PASS descriptor.set is an instance of Function
+PASS descriptor.set is undefined.
 PASS descriptor.enumerable is true
 PASS descriptor.configurable is true
 PASS descriptor.get.call(nonWindowObject) threw exception TypeError: The DOMWindow.navigator getter can only be used on instances of DOMWindow.

Modified: trunk/LayoutTests/js/getOwnPropertyDescriptor-window-attributes.html (196796 => 196797)


--- trunk/LayoutTests/js/getOwnPropertyDescriptor-window-attributes.html	2016-02-19 05:12:02 UTC (rev 196796)
+++ trunk/LayoutTests/js/getOwnPropertyDescriptor-window-attributes.html	2016-02-19 05:17:32 UTC (rev 196797)
@@ -28,7 +28,7 @@
 debug("");
 debug("* Window.navigator");
 descriptor = Object.getOwnPropertyDescriptor(window, "navigator");
-checkWindowPropertyDescriptor(descriptor, false);
+checkWindowPropertyDescriptor(descriptor, true);
 shouldBeTrue("descriptor.get.call(window) === window.navigator");
 shouldBeTrue("descriptor.get.call() === window.navigator");
 

Modified: trunk/Source/WebCore/ChangeLog (196796 => 196797)


--- trunk/Source/WebCore/ChangeLog	2016-02-19 05:12:02 UTC (rev 196796)
+++ trunk/Source/WebCore/ChangeLog	2016-02-19 05:17:32 UTC (rev 196797)
@@ -1,5 +1,23 @@
 2016-02-18  Chris Dumez  <[email protected]>
 
+        window.history / window.navigator should not be replaceable
+        https://bugs.webkit.org/show_bug.cgi?id=154412
+
+        Reviewed by Ryosuke Niwa.
+
+        window.history / window.navigator should not be replaceable as per
+        the latest HTML specification:
+        https://html.spec.whatwg.org/multipage/browsers.html#the-window-object
+
+        Firefox and Chrome already match the specification. This patch aligns
+        our behavior.
+
+        No new tests, already covered by existing tests.
+
+        * page/DOMWindow.idl:
+
+2016-02-18  Chris Dumez  <[email protected]>
+
         HTMLTableHeaderCellElement.scope should only return known values
         https://bugs.webkit.org/show_bug.cgi?id=154423
         <rdar://problem/24731018>

Modified: trunk/Source/WebCore/page/DOMWindow.idl (196796 => 196797)


--- trunk/Source/WebCore/page/DOMWindow.idl	2016-02-19 05:12:02 UTC (rev 196796)
+++ trunk/Source/WebCore/page/DOMWindow.idl	2016-02-19 05:17:32 UTC (rev 196797)
@@ -40,14 +40,14 @@
 ] interface DOMWindow : EventTarget {
     // DOM Level 0
     [Replaceable] readonly attribute Screen screen;
-    [Replaceable] readonly attribute History history;
+    readonly attribute History history;
     [Replaceable] readonly attribute BarProp locationbar;
     [Replaceable] readonly attribute BarProp menubar;
     [Replaceable] readonly attribute BarProp personalbar;
     [Replaceable] readonly attribute BarProp scrollbars;
     [Replaceable] readonly attribute BarProp statusbar;
     [Replaceable] readonly attribute BarProp toolbar;
-    [Replaceable] readonly attribute Navigator navigator;
+    readonly attribute Navigator navigator;
     [Replaceable] readonly attribute Navigator clientInformation;
     readonly attribute Crypto crypto;
     [DoNotCheckSecurity, CustomSetter, Unforgeable] attribute Location location;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to