Title: [212178] trunk
Revision
212178
Author
cdu...@apple.com
Date
2017-02-10 20:40:38 -0800 (Fri, 10 Feb 2017)

Log Message

document.origin doesn't match spec
https://bugs.webkit.org/show_bug.cgi?id=168022

Reviewed by Sam Weinig.

LayoutTests/imported/w3c:

Rebaseline test now that document.origin has the right format.

* web-platform-tests/dom/nodes/Node-cloneNode-expected.txt:

Source/WebCore:

Update document.origin to return the origin in the expected format:
- https://dom.spec.whatwg.org/#dom-document-origin

Change: "https_webkit.org_0 -> "https://webkit.org".

The new behavior matches Firefox and Chrome.

No new tests, updated existing tests.

* dom/Document.cpp:
(WebCore::Document::origin):

LayoutTests:

* http/tests/media/media-stream/enumerate-devices-source-id-persistent.html:
Fix test that was passing only because the document.origin would never match the
expected string:
- Move idCounts to the global scope has the handler function is called 3 times
  and we need to properly update the same idCounts object in all 3 calls.
- Fix initialization of idCounts to start at 1, not 0. Otherwise, idCounts[uniqueID]
  is 0 instead of 1.
- Use a Map instead of an array since the ids are UUID strings, not integers.
- Fix check for non-unique ids, was idCounts[deviceId] == 1 instead of
 idCounts[deviceId] != 1.

* http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/form-upgrade.html:
* http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/iframe-upgrade.https.html:
* http/tests/ssl/iframe-upgrade.https.html:
Update / rebaseline now that document.origin has the right format.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (212177 => 212178)


--- trunk/LayoutTests/ChangeLog	2017-02-11 04:05:06 UTC (rev 212177)
+++ trunk/LayoutTests/ChangeLog	2017-02-11 04:40:38 UTC (rev 212178)
@@ -1,3 +1,26 @@
+2017-02-10  Chris Dumez  <cdu...@apple.com>
+
+        document.origin doesn't match spec
+        https://bugs.webkit.org/show_bug.cgi?id=168022
+
+        Reviewed by Sam Weinig.
+
+        * http/tests/media/media-stream/enumerate-devices-source-id-persistent.html:
+        Fix test that was passing only because the document.origin would never match the
+        expected string:
+        - Move idCounts to the global scope has the handler function is called 3 times
+          and we need to properly update the same idCounts object in all 3 calls.
+        - Fix initialization of idCounts to start at 1, not 0. Otherwise, idCounts[uniqueID]
+          is 0 instead of 1.
+        - Use a Map instead of an array since the ids are UUID strings, not integers.
+        - Fix check for non-unique ids, was idCounts[deviceId] == 1 instead of
+         idCounts[deviceId] != 1.
+
+        * http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/form-upgrade.html:
+        * http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/iframe-upgrade.https.html:
+        * http/tests/ssl/iframe-upgrade.https.html:
+        Update / rebaseline now that document.origin has the right format.
+
 2017-02-10  Simon Fraser  <simon.fra...@apple.com>
 
         REGRESSION (r211845): [ios-simulator] LayoutTest compositing/masks/solid-color-masked.html is a flaky failure

Modified: trunk/LayoutTests/http/tests/media/media-stream/enumerate-devices-source-id-persistent.html (212177 => 212178)


--- trunk/LayoutTests/http/tests/media/media-stream/enumerate-devices-source-id-persistent.html	2017-02-11 04:05:06 UTC (rev 212177)
+++ trunk/LayoutTests/http/tests/media/media-stream/enumerate-devices-source-id-persistent.html	2017-02-11 04:40:38 UTC (rev 212178)
@@ -7,6 +7,7 @@
         <script src=""
         <script>
             var frameInfos = [];
+            var idCounts = new Map();
             window.jsTestIsAsync = true;
 
             if (window.testRunner) {
@@ -22,11 +23,12 @@
 
             function handler(event) 
             {
-                var idCounts = [];
-
                 event.data.deviceIds.forEach(function(id) {
                     frameInfos.push({origin : event.data.origin, deviceId : id});
-                    idCounts[id] = idCounts[id] === undefined ? 0 : ++idCounts[id];
+                    if (idCounts.has(id))
+                        idCounts.set(id, idCounts.get(id) + 1);
+                    else
+                        idCounts.set(id, 1);
                 });
 
                 if (frameInfos.length != 6)
@@ -36,12 +38,12 @@
                 for (var i = 0; i < frameInfos.length; i++) {
                     var deviceId = frameInfos[i].deviceId;
                     if (frameInfos[i].origin.indexOf("http://localhost:8000") == 0) {
-                        if (idCounts[deviceId] < 2) {
+                        if (idCounts.get(deviceId) < 2) {
                             testFailed(`: device ID in ${frameInfos[i].origin} is unique`);
                             success = false;
                         }
                     } else {
-                        if (idCounts[deviceId] == 1) {
+                        if (idCounts.get(deviceId) != 1) {
                             testFailed(`: device ID in ${frameInfos[i].origin} is not unique`);
                             success = false;
                         }

Modified: trunk/LayoutTests/http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/form-upgrade.html (212177 => 212178)


--- trunk/LayoutTests/http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/form-upgrade.html	2017-02-11 04:05:06 UTC (rev 212177)
+++ trunk/LayoutTests/http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/form-upgrade.html	2017-02-11 04:40:38 UTC (rev 212178)
@@ -14,7 +14,7 @@
 
     window.addEventListener('message', t.step_func(e => {
         if (e.source == iframe.contentWindow) {
-            assert_equals("https_127.0.0.1_8443", e.data.origin);
+            assert_equals("https://127.0.0.1:8443", e.data.origin);
             t.done();
         }
     }));
@@ -30,7 +30,7 @@
 
     window.addEventListener('message', t.step_func(e => {
         if (e.source == iframe.contentWindow) {
-            assert_equals(e.data.origin, "https_localhost_8443");
+            assert_equals("https://localhost:8443", e.data.origin);
             t.done();
         }
     }));
@@ -38,4 +38,4 @@
     document.body.appendChild(iframe);
 }, "Cross-host form submissions are upgraded.");
 </script>
-</body>
\ No newline at end of file
+</body>

Modified: trunk/LayoutTests/http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/iframe-upgrade.https.html (212177 => 212178)


--- trunk/LayoutTests/http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/iframe-upgrade.https.html	2017-02-11 04:05:06 UTC (rev 212177)
+++ trunk/LayoutTests/http/tests/security/contentSecurityPolicy/upgrade-insecure-requests/iframe-upgrade.https.html	2017-02-11 04:40:38 UTC (rev 212178)
@@ -17,7 +17,7 @@
 
     window.addEventListener('message', t.step_func(e => {
         if (e.source == iframe.contentWindow) {
-            assert_equals(e.data.origin, "https_127.0.0.1_8443");
+            assert_equals("https://127.0.0.1:8443", e.data.origin);
             t.done();
         }
     }));
@@ -31,7 +31,7 @@
 
     window.addEventListener('message', t.step_func(e => {
         if (e.source == iframe.contentWindow) {
-            assert_equals(e.data.origin, "https_localhost_8443");
+            assert_equals("https://localhost:8443", e.data.origin);
             t.done();
         }
     }));
@@ -46,7 +46,7 @@
 
     window.addEventListener('message', t.step_func(e => {
         if (e.source == iframe.contentWindow) {
-            assert_equals(e.data.origin, "http_localhost_8000");
+            assert_equals("http://localhost:8000", e.data.origin);
             t.done();
         }
     }));
@@ -54,4 +54,4 @@
     document.body.appendChild(iframe);
 }, "Upgrade policy does NOT cascade to nested, cross-host frames.");
 </script>
-</body>
\ No newline at end of file
+</body>

Modified: trunk/LayoutTests/http/tests/ssl/iframe-upgrade.https.html (212177 => 212178)


--- trunk/LayoutTests/http/tests/ssl/iframe-upgrade.https.html	2017-02-11 04:05:06 UTC (rev 212177)
+++ trunk/LayoutTests/http/tests/ssl/iframe-upgrade.https.html	2017-02-11 04:40:38 UTC (rev 212178)
@@ -17,7 +17,7 @@
 
     window.addEventListener('message', t.step_func(e => {
         if (e.source == iframe.contentWindow) {
-            assert_equals(e.data.origin, "https_127.0.0.1_8443");
+            assert_equals("https://127.0.0.1:8443", e.data.origin);
             t.done();
         }
     }));
@@ -31,7 +31,7 @@
 
     window.addEventListener('message', t.step_func(e => {
         if (e.source == iframe.contentWindow) {
-            assert_equals(e.data.origin, "https_localhost_8443");
+            assert_equals("https://localhost:8443", e.data.origin);
             t.done();
         }
     }));
@@ -46,7 +46,7 @@
 
     window.addEventListener('message', t.step_func(e => {
         if (e.source == iframe.contentWindow) {
-            assert_equals(e.data.origin, "https_127.0.0.1_8443");
+            assert_equals("https://127.0.0.1:8443", e.data.origin);
             t.done();
         }
     }));
@@ -54,4 +54,4 @@
     document.body.appendChild(iframe);
 }, "Upgrade policy cascades to nested, same-host frames.");
 </script>
-</body>
\ No newline at end of file
+</body>

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (212177 => 212178)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2017-02-11 04:05:06 UTC (rev 212177)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2017-02-11 04:40:38 UTC (rev 212178)
@@ -1,3 +1,14 @@
+2017-02-10  Chris Dumez  <cdu...@apple.com>
+
+        document.origin doesn't match spec
+        https://bugs.webkit.org/show_bug.cgi?id=168022
+
+        Reviewed by Sam Weinig.
+
+        Rebaseline test now that document.origin has the right format.
+
+        * web-platform-tests/dom/nodes/Node-cloneNode-expected.txt:
+
 2017-02-10  Youenn Fablet  <you...@apple.com>
 
         [Fetch API] fetch fails when undefined is passed as headers

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/dom/nodes/Node-cloneNode-expected.txt (212177 => 212178)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/dom/nodes/Node-cloneNode-expected.txt	2017-02-11 04:05:06 UTC (rev 212177)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/dom/nodes/Node-cloneNode-expected.txt	2017-02-11 04:40:38 UTC (rev 212178)
@@ -129,7 +129,7 @@
 PASS createElementNS non-HTML 
 PASS createProcessingInstruction 
 PASS implementation.createDocumentType 
-FAIL implementation.createDocument assert_equals: expected "null" but got "http_localhost_8800"
+FAIL implementation.createDocument assert_equals: expected "null" but got "http://localhost:8800"
 PASS implementation.createHTMLDocument 
 PASS node with children 
 

Modified: trunk/Source/WebCore/ChangeLog (212177 => 212178)


--- trunk/Source/WebCore/ChangeLog	2017-02-11 04:05:06 UTC (rev 212177)
+++ trunk/Source/WebCore/ChangeLog	2017-02-11 04:40:38 UTC (rev 212178)
@@ -1,3 +1,22 @@
+2017-02-10  Chris Dumez  <cdu...@apple.com>
+
+        document.origin doesn't match spec
+        https://bugs.webkit.org/show_bug.cgi?id=168022
+
+        Reviewed by Sam Weinig.
+
+        Update document.origin to return the origin in the expected format:
+        - https://dom.spec.whatwg.org/#dom-document-origin
+
+        Change: "https_webkit.org_0 -> "https://webkit.org".
+
+        The new behavior matches Firefox and Chrome.
+
+        No new tests, updated existing tests.
+
+        * dom/Document.cpp:
+        (WebCore::Document::origin):
+
 2017-02-10  Daniel Bates  <daba...@apple.com>
 
         Attempt to fix the build following <https://trac.webkit.org/changeset/212173>

Modified: trunk/Source/WebCore/dom/Document.cpp (212177 => 212178)


--- trunk/Source/WebCore/dom/Document.cpp	2017-02-11 04:05:06 UTC (rev 212177)
+++ trunk/Source/WebCore/dom/Document.cpp	2017-02-11 04:40:38 UTC (rev 212178)
@@ -4288,7 +4288,7 @@
 
 String Document::origin() const
 {
-    return SecurityOriginData::fromSecurityOrigin(securityOrigin()).databaseIdentifier();
+    return securityOrigin().toString();
 }
 
 String Document::domain() const
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to