Title: [192810] trunk
Revision
192810
Author
cdu...@apple.com
Date
2015-11-30 11:27:26 -0800 (Mon, 30 Nov 2015)

Log Message

location.origin is undefined in a web worker
https://bugs.webkit.org/show_bug.cgi?id=151614

Reviewed by Darin Adler.

Source/WebCore:

Expose location.origin to web workers, as per:
https://html.spec.whatwg.org/multipage/workers.html#workerlocation

This behavior is consistent with the behavior of Firefox and Chrome.

Test: fast/workers/worker-location.html

* workers/WorkerLocation.cpp:
(WebCore::WorkerLocation::origin):
* workers/WorkerLocation.h:
* workers/WorkerLocation.idl:

LayoutTests:

Update existing layout test to confirm the existence of location.origin when in a
WorkerGlobalScope.

* fast/workers/resources/worker-location.js:
* fast/workers/worker-location-expected.txt:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (192809 => 192810)


--- trunk/LayoutTests/ChangeLog	2015-11-30 19:25:12 UTC (rev 192809)
+++ trunk/LayoutTests/ChangeLog	2015-11-30 19:27:26 UTC (rev 192810)
@@ -1,3 +1,16 @@
+2015-11-30  Chris Dumez  <cdu...@apple.com>
+
+        location.origin is undefined in a web worker
+        https://bugs.webkit.org/show_bug.cgi?id=151614
+
+        Reviewed by Darin Adler.
+
+        Update existing layout test to confirm the existence of location.origin when in a
+        WorkerGlobalScope.
+
+        * fast/workers/resources/worker-location.js:
+        * fast/workers/worker-location-expected.txt:
+
 2015-11-30  Brady Eidson  <beid...@apple.com>
 
         Modern IDB: Support updating cursor values when the object store uses inline keys.

Modified: trunk/LayoutTests/fast/workers/resources/worker-location.js (192809 => 192810)


--- trunk/LayoutTests/fast/workers/resources/worker-location.js	2015-11-30 19:25:12 UTC (rev 192809)
+++ trunk/LayoutTests/fast/workers/resources/worker-location.js	2015-11-30 19:27:26 UTC (rev 192810)
@@ -30,6 +30,7 @@
 worker.postMessage("eval location.pathname");
 worker.postMessage("eval location.search");
 worker.postMessage("eval location.hash");
+worker.postMessage("eval location.origin");
 worker.postMessage("eval foo//bar");
 
 worker._onmessage_ = function(evt) {

Modified: trunk/LayoutTests/fast/workers/worker-location-expected.txt (192809 => 192810)


--- trunk/LayoutTests/fast/workers/worker-location-expected.txt	2015-11-30 19:25:12 UTC (rev 192809)
+++ trunk/LayoutTests/fast/workers/worker-location-expected.txt	2015-11-30 19:27:26 UTC (rev 192810)
@@ -11,5 +11,6 @@
 location.pathname: <...>/fast/workers/resources/worker-common.js
 location.search: 
 location.hash: 
+location.origin: file://
 DONE
 

Modified: trunk/Source/WebCore/ChangeLog (192809 => 192810)


--- trunk/Source/WebCore/ChangeLog	2015-11-30 19:25:12 UTC (rev 192809)
+++ trunk/Source/WebCore/ChangeLog	2015-11-30 19:27:26 UTC (rev 192810)
@@ -1,3 +1,22 @@
+2015-11-30  Chris Dumez  <cdu...@apple.com>
+
+        location.origin is undefined in a web worker
+        https://bugs.webkit.org/show_bug.cgi?id=151614
+
+        Reviewed by Darin Adler.
+
+        Expose location.origin to web workers, as per:
+        https://html.spec.whatwg.org/multipage/workers.html#workerlocation
+
+        This behavior is consistent with the behavior of Firefox and Chrome.
+
+        Test: fast/workers/worker-location.html
+
+        * workers/WorkerLocation.cpp:
+        (WebCore::WorkerLocation::origin):
+        * workers/WorkerLocation.h:
+        * workers/WorkerLocation.idl:
+
 2015-11-30  Brady Eidson  <beid...@apple.com>
 
         Modern IDB: Support updating cursor values when the object store uses inline keys.

Modified: trunk/Source/WebCore/workers/WorkerLocation.cpp (192809 => 192810)


--- trunk/Source/WebCore/workers/WorkerLocation.cpp	2015-11-30 19:25:12 UTC (rev 192809)
+++ trunk/Source/WebCore/workers/WorkerLocation.cpp	2015-11-30 19:27:26 UTC (rev 192810)
@@ -25,9 +25,9 @@
  */
 
 #include "config.h"
-
 #include "WorkerLocation.h"
 
+#include "SecurityOrigin.h"
 #include <wtf/text/WTFString.h>
 
 namespace WebCore {
@@ -72,5 +72,9 @@
     return m_url.fragmentIdentifier().isEmpty() ? emptyString() : "#" + m_url.fragmentIdentifier();
 }
 
+String WorkerLocation::origin() const
+{
+    return SecurityOrigin::create(m_url)->toString();
+}
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/workers/WorkerLocation.h (192809 => 192810)


--- trunk/Source/WebCore/workers/WorkerLocation.h	2015-11-30 19:25:12 UTC (rev 192809)
+++ trunk/Source/WebCore/workers/WorkerLocation.h	2015-11-30 19:27:26 UTC (rev 192810)
@@ -54,6 +54,7 @@
         String pathname() const;
         String search() const;
         String hash() const;
+        String origin() const;
 
         String toString() const { return href(); }
 

Modified: trunk/Source/WebCore/workers/WorkerLocation.idl (192809 => 192810)


--- trunk/Source/WebCore/workers/WorkerLocation.idl	2015-11-30 19:25:12 UTC (rev 192809)
+++ trunk/Source/WebCore/workers/WorkerLocation.idl	2015-11-30 19:27:26 UTC (rev 192810)
@@ -39,6 +39,7 @@
     readonly attribute DOMString pathname;
     readonly attribute DOMString search;
     readonly attribute DOMString hash;
+    readonly attribute DOMString origin;
 
     [NotEnumerable] DOMString toString();
 };
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to