Title: [223922] trunk
Revision
223922
Author
cdu...@apple.com
Date
2017-10-24 14:22:54 -0700 (Tue, 24 Oct 2017)

Log Message

Add initial implementation for serviceWorker.postMessage()
https://bugs.webkit.org/show_bug.cgi?id=178534

Reviewed by Youenn Fablet.

Source/WebCore:

Add initial implementation for serviceWorker.postMessage():
- https://w3c.github.io/ServiceWorker/#service-worker-postmessage

Test: http/tests/workers/service/basic-ServiceWorker-postMessage.https.html

* CMakeLists.txt:
* DerivedSources.make:
* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSBindingsAllInOne.cpp:
* bindings/js/JSExtendableMessageEvent.cpp: Added.
(WebCore::JSExtendableMessageEvent::data const):
* bindings/js/WebCoreBuiltinNames.h:
* dom/Document.h:
* dom/EventNames.in:
* dom/MessagePortChannel.h:
* dom/ScriptExecutionContext.h:
* workers/WorkerGlobalScope.h:
* workers/service/ExtendableEvent.cpp:
(WebCore::ExtendableEvent::ExtendableEvent):
(WebCore::ExtendableEvent::~ExtendableEvent):
* workers/service/ExtendableEvent.h:
* workers/service/ExtendableMessageEvent.cpp: Added.
(WebCore::ExtendableMessageEvent::create):
(WebCore::ExtendableMessageEvent::ExtendableMessageEvent):
(WebCore::ExtendableMessageEvent::~ExtendableMessageEvent):
* workers/service/ExtendableMessageEvent.h: Added.
* workers/service/ExtendableMessageEvent.idl: Added.
* workers/service/ServiceWorker.cpp:
(WebCore::ServiceWorker::ServiceWorker):
(WebCore::ServiceWorker::postMessage):
(WebCore::ServiceWorker::state const):
(WebCore::ServiceWorker::scriptExecutionContext const):
* workers/service/ServiceWorker.h:
* workers/service/ServiceWorkerContainer.cpp:
(WebCore::ServiceWorkerContainer::controller const):
* workers/service/ServiceWorkerContainer.h:
* workers/service/ServiceWorkerGlobalScope.cpp:
(WebCore::ServiceWorkerGlobalScope::thread):
* workers/service/ServiceWorkerGlobalScope.h:
(isType):
* workers/service/context/ServiceWorkerThread.cpp:
(WebCore::ServiceWorkerThread::postMessageToServiceWorkerGlobalScope):
* workers/service/context/ServiceWorkerThread.h:
* workers/service/server/SWClientConnection.h:

Source/WebKit:

Add initial implementation for serviceWorker.postMessage():
- https://w3c.github.io/ServiceWorker/#service-worker-postmessage

* StorageProcess/ServiceWorker/WebSWServerConnection.cpp:
(WebKit::WebSWServerConnection::postMessageToServiceWorkerGlobalScope):
* StorageProcess/ServiceWorker/WebSWServerConnection.h:
* StorageProcess/ServiceWorker/WebSWServerConnection.messages.in:
* WebProcess/Storage/ServiceWorkerContextManager.cpp:
(WebKit::ServiceWorkerContextManager::postMessageToServiceWorkerGlobalScope):
* WebProcess/Storage/ServiceWorkerContextManager.h:
* WebProcess/Storage/ServiceWorkerContextManager.messages.in:
* WebProcess/Storage/WebSWClientConnection.cpp:
(WebKit::WebSWClientConnection::postMessageToServiceWorkerGlobalScope):
* WebProcess/Storage/WebSWClientConnection.h:

LayoutTests:

Add layout test coverage.

* http/tests/workers/service/basic-ServiceWorker-postMessage.https-expected.txt: Added.
* http/tests/workers/service/basic-ServiceWorker-postMessage.https.html: Added.
* http/tests/workers/service/resources/basic-ServiceWorker-postMessage-worker.js: Added.
* http/tests/workers/service/resources/basic-ServiceWorker-postMessage.js: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (223921 => 223922)


--- trunk/LayoutTests/ChangeLog	2017-10-24 21:17:17 UTC (rev 223921)
+++ trunk/LayoutTests/ChangeLog	2017-10-24 21:22:54 UTC (rev 223922)
@@ -1,3 +1,17 @@
+2017-10-24  Chris Dumez  <cdu...@apple.com>
+
+        Add initial implementation for serviceWorker.postMessage()
+        https://bugs.webkit.org/show_bug.cgi?id=178534
+
+        Reviewed by Youenn Fablet.
+
+        Add layout test coverage.
+
+        * http/tests/workers/service/basic-ServiceWorker-postMessage.https-expected.txt: Added.
+        * http/tests/workers/service/basic-ServiceWorker-postMessage.https.html: Added.
+        * http/tests/workers/service/resources/basic-ServiceWorker-postMessage-worker.js: Added.
+        * http/tests/workers/service/resources/basic-ServiceWorker-postMessage.js: Added.
+
 2017-10-24  Joseph Pecoraro  <pecor...@apple.com>
 
         Unreviewed test gardening. Update inspector/network/har tests.

Added: trunk/LayoutTests/http/tests/workers/service/basic-ServiceWorker-postMessage.https-expected.txt (0 => 223922)


--- trunk/LayoutTests/http/tests/workers/service/basic-ServiceWorker-postMessage.https-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/workers/service/basic-ServiceWorker-postMessage.https-expected.txt	2017-10-24 21:22:54 UTC (rev 223922)
@@ -0,0 +1,4 @@
+PASS: Status code is 200
+PASS: Status text is Worker received the message event. messageEvent.origin was https://127.0.0.1:8443
+PASS: Source is Service worker
+

Added: trunk/LayoutTests/http/tests/workers/service/basic-ServiceWorker-postMessage.https.html (0 => 223922)


--- trunk/LayoutTests/http/tests/workers/service/basic-ServiceWorker-postMessage.https.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/workers/service/basic-ServiceWorker-postMessage.https.html	2017-10-24 21:22:54 UTC (rev 223922)
@@ -0,0 +1,9 @@
+<html>
+<head>
+<script src=""
+</head>
+<body>
+
+<script src=""
+</body>
+</html>

Added: trunk/LayoutTests/http/tests/workers/service/resources/basic-ServiceWorker-postMessage-worker.js (0 => 223922)


--- trunk/LayoutTests/http/tests/workers/service/resources/basic-ServiceWorker-postMessage-worker.js	                        (rev 0)
+++ trunk/LayoutTests/http/tests/workers/service/resources/basic-ServiceWorker-postMessage-worker.js	2017-10-24 21:22:54 UTC (rev 223922)
@@ -0,0 +1,14 @@
+let responseToSend = { status: 404, statusText: "Not Found" };
+
+self.addEventListener("message", (event) => {
+    responseToSend = event.data;
+    responseToSend.statusText += " messageEvent.origin was " + event.origin;
+});
+
+self.addEventListener("fetch", (event) => {
+    if (event.request.url.indexOf("test1") !== -1) {
+        event.respondWith(new Response(null, responseToSend));
+        return;
+    }
+    event.respondWith(Response.error());
+});

Added: trunk/LayoutTests/http/tests/workers/service/resources/basic-ServiceWorker-postMessage.js (0 => 223922)


--- trunk/LayoutTests/http/tests/workers/service/resources/basic-ServiceWorker-postMessage.js	                        (rev 0)
+++ trunk/LayoutTests/http/tests/workers/service/resources/basic-ServiceWorker-postMessage.js	2017-10-24 21:22:54 UTC (rev 223922)
@@ -0,0 +1,37 @@
+function done()
+{
+    finishSWTest();
+}
+
+async function test()
+{
+    try {
+        await navigator.serviceWorker.register("resources/basic-ServiceWorker-postMessage-worker.js", { });
+
+        navigator.serviceWorker.controller.postMessage({ status: 200, statusText: "Worker received the message event." });
+
+        let response = await fetch("test1");
+        if (response.status == 200)
+            log("PASS: Status code is " + response.status);
+        else
+            log("FAIL: Status code is " + response.status);
+
+        if (response.statusText.startsWith("Worker received the message"))
+            log("PASS: Status text is " + response.statusText);
+        else
+            log("FAIL: Status text is " + response.statusText);
+
+        if (window.internals) {
+            let source = internals.fetchResponseSource(response);
+            if (source === "Service worker")
+                log("PASS: Source is " + source);
+            else
+                log("FAIL: Source is " + source);
+        }
+    } catch(e) {
+        log("Got exception: " + e);
+    }
+    finishSWTest();
+}
+
+test();

Modified: trunk/Source/WebCore/CMakeLists.txt (223921 => 223922)


--- trunk/Source/WebCore/CMakeLists.txt	2017-10-24 21:17:17 UTC (rev 223921)
+++ trunk/Source/WebCore/CMakeLists.txt	2017-10-24 21:22:54 UTC (rev 223922)
@@ -801,6 +801,7 @@
 
     workers/service/ExtendableEvent.idl
     workers/service/ExtendableEventInit.idl
+    workers/service/ExtendableMessageEvent.idl
     workers/service/FetchEvent.idl
     workers/service/ServiceWorker.idl
     workers/service/ServiceWorkerClient.idl
@@ -2247,6 +2248,7 @@
     workers/WorkerThread.cpp
 
     workers/service/ExtendableEvent.cpp
+    workers/service/ExtendableMessageEvent.cpp
     workers/service/FetchEvent.cpp
     workers/service/ServiceWorker.cpp
     workers/service/ServiceWorkerClient.cpp

Modified: trunk/Source/WebCore/ChangeLog (223921 => 223922)


--- trunk/Source/WebCore/ChangeLog	2017-10-24 21:17:17 UTC (rev 223921)
+++ trunk/Source/WebCore/ChangeLog	2017-10-24 21:22:54 UTC (rev 223922)
@@ -1,3 +1,56 @@
+2017-10-24  Chris Dumez  <cdu...@apple.com>
+
+        Add initial implementation for serviceWorker.postMessage()
+        https://bugs.webkit.org/show_bug.cgi?id=178534
+
+        Reviewed by Youenn Fablet.
+
+        Add initial implementation for serviceWorker.postMessage():
+        - https://w3c.github.io/ServiceWorker/#service-worker-postmessage
+
+        Test: http/tests/workers/service/basic-ServiceWorker-postMessage.https.html
+
+        * CMakeLists.txt:
+        * DerivedSources.make:
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * bindings/js/JSBindingsAllInOne.cpp:
+        * bindings/js/JSExtendableMessageEvent.cpp: Added.
+        (WebCore::JSExtendableMessageEvent::data const):
+        * bindings/js/WebCoreBuiltinNames.h:
+        * dom/Document.h:
+        * dom/EventNames.in:
+        * dom/MessagePortChannel.h:
+        * dom/ScriptExecutionContext.h:
+        * workers/WorkerGlobalScope.h:
+        * workers/service/ExtendableEvent.cpp:
+        (WebCore::ExtendableEvent::ExtendableEvent):
+        (WebCore::ExtendableEvent::~ExtendableEvent):
+        * workers/service/ExtendableEvent.h:
+        * workers/service/ExtendableMessageEvent.cpp: Added.
+        (WebCore::ExtendableMessageEvent::create):
+        (WebCore::ExtendableMessageEvent::ExtendableMessageEvent):
+        (WebCore::ExtendableMessageEvent::~ExtendableMessageEvent):
+        * workers/service/ExtendableMessageEvent.h: Added.
+        * workers/service/ExtendableMessageEvent.idl: Added.
+        * workers/service/ServiceWorker.cpp:
+        (WebCore::ServiceWorker::ServiceWorker):
+        (WebCore::ServiceWorker::postMessage):
+        (WebCore::ServiceWorker::state const):
+        (WebCore::ServiceWorker::scriptExecutionContext const):
+        * workers/service/ServiceWorker.h:
+        * workers/service/ServiceWorkerContainer.cpp:
+        (WebCore::ServiceWorkerContainer::controller const):
+        * workers/service/ServiceWorkerContainer.h:
+        * workers/service/ServiceWorkerGlobalScope.cpp:
+        (WebCore::ServiceWorkerGlobalScope::thread):
+        * workers/service/ServiceWorkerGlobalScope.h:
+        (isType):
+        * workers/service/context/ServiceWorkerThread.cpp:
+        (WebCore::ServiceWorkerThread::postMessageToServiceWorkerGlobalScope):
+        * workers/service/context/ServiceWorkerThread.h:
+        * workers/service/server/SWClientConnection.h:
+
 2017-10-24  Andy Estes  <aes...@apple.com>
 
         [Payment Request] Implement the "PaymentRequest updated" algorithm

Modified: trunk/Source/WebCore/DerivedSources.make (223921 => 223922)


--- trunk/Source/WebCore/DerivedSources.make	2017-10-24 21:17:17 UTC (rev 223921)
+++ trunk/Source/WebCore/DerivedSources.make	2017-10-24 21:22:54 UTC (rev 223922)
@@ -922,6 +922,7 @@
     $(WebCore)/workers/WorkerType.idl \
     $(WebCore)/workers/service/ExtendableEvent.idl \
     $(WebCore)/workers/service/ExtendableEventInit.idl \
+    $(WebCore)/workers/service/ExtendableMessageEvent.idl \
     $(WebCore)/workers/service/FetchEvent.idl \
     $(WebCore)/workers/service/ServiceWorker.idl \
     $(WebCore)/workers/service/ServiceWorkerClient.idl \

Modified: trunk/Source/WebCore/Sources.txt (223921 => 223922)


--- trunk/Source/WebCore/Sources.txt	2017-10-24 21:17:17 UTC (rev 223921)
+++ trunk/Source/WebCore/Sources.txt	2017-10-24 21:22:54 UTC (rev 223922)
@@ -370,6 +370,7 @@
 bindings/js/JSEventCustom.cpp
 bindings/js/JSEventListener.cpp
 bindings/js/JSEventTargetCustom.cpp
+bindings/js/JSExtendableMessageEventCustom.cpp
 bindings/js/JSFileSystemEntryCustom.cpp
 bindings/js/JSHTMLCollectionCustom.cpp
 bindings/js/JSHTMLDocumentCustom.cpp
@@ -1080,6 +1081,7 @@
 JSEventTarget.cpp
 JSExtendableEvent.cpp
 JSExtendableEventInit.cpp
+JSExtendableMessageEvent.cpp
 JSFederatedCredential.cpp
 JSFederatedCredentialInit.cpp
 JSFederatedCredentialRequestOptions.cpp

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (223921 => 223922)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2017-10-24 21:17:17 UTC (rev 223921)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2017-10-24 21:22:54 UTC (rev 223922)
@@ -2955,6 +2955,7 @@
 		830784B21C52EE2C00104D1D /* XMLDocument.h in Headers */ = {isa = PBXBuildFile; fileRef = 830784B11C52EE1900104D1D /* XMLDocument.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		830A36BD1DAC5FAD006D7D09 /* JSMouseEventInit.h in Headers */ = {isa = PBXBuildFile; fileRef = 830A36BB1DAC5FA7006D7D09 /* JSMouseEventInit.h */; };
 		83120C701C56F3F6001CB112 /* HTMLDataElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 831D1F291C56ECA000F5F6C0 /* HTMLDataElement.cpp */; };
+		83102B271F9EADD900E404B9 /* JSExtendableMessageEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 83102B231F9EADC200E404B9 /* JSExtendableMessageEvent.h */; };
 		83120C711C56F3FB001CB112 /* HTMLDataElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 834B86A71C56E83A00F3F0E3 /* HTMLDataElement.h */; };
 		8321507E1F27EA1B0095B136 /* NavigatorBeacon.h in Headers */ = {isa = PBXBuildFile; fileRef = 8321507B1F27EA150095B136 /* NavigatorBeacon.h */; };
 		832B843419D8E55100B26055 /* SVGAnimateElementBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 832B843319D8E55100B26055 /* SVGAnimateElementBase.h */; };
@@ -2998,6 +2999,8 @@
 		837964CF1F8DB69D00218EA0 /* GeolocationPositionIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 837964CE1F8DB69A00218EA0 /* GeolocationPositionIOS.mm */; };
 		837A80131E1E127300026B9F /* Localizable.stringsdict in Resources */ = {isa = PBXBuildFile; fileRef = 837A80111E1E127300026B9F /* Localizable.stringsdict */; };
 		837B7D201DC3F55000D051FC /* ValidationBubbleIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 837B7D1F1DC3F54C00D051FC /* ValidationBubbleIOS.mm */; };
+		837FB3441F9EA06D00D0FC31 /* ExtendableMessageEvent.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 837FB3421F9EA06700D0FC31 /* ExtendableMessageEvent.cpp */; };
+		837FB3451F9EA06D00D0FC31 /* ExtendableMessageEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 837FB3401F9EA06600D0FC31 /* ExtendableMessageEvent.h */; };
 		8386A96D19F61B2E00E1EC4A /* StyleBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = 8386A96C19F61B2E00E1EC4A /* StyleBuilder.h */; };
 		838867351D13BA5F003697D0 /* RenderObjectEnums.h in Headers */ = {isa = PBXBuildFile; fileRef = 838867341D13BA59003697D0 /* RenderObjectEnums.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		838EF5381DC149E2008F0C39 /* IDBTransactionMode.h in Headers */ = {isa = PBXBuildFile; fileRef = 838EF5361DC149DA008F0C39 /* IDBTransactionMode.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -10720,6 +10723,9 @@
 		830784B11C52EE1900104D1D /* XMLDocument.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XMLDocument.h; sourceTree = "<group>"; };
 		830A36BA1DAC5FA7006D7D09 /* JSMouseEventInit.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMouseEventInit.cpp; sourceTree = "<group>"; };
 		830A36BB1DAC5FA7006D7D09 /* JSMouseEventInit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMouseEventInit.h; sourceTree = "<group>"; };
+		83102B231F9EADC200E404B9 /* JSExtendableMessageEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSExtendableMessageEvent.h; sourceTree = "<group>"; };
+		83102B251F9EADC200E404B9 /* JSExtendableMessageEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSExtendableMessageEvent.cpp; sourceTree = "<group>"; };
+		831C46C31F9EE5E000EBD450 /* JSExtendableMessageEventCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSExtendableMessageEventCustom.cpp; sourceTree = "<group>"; };
 		831D1F291C56ECA000F5F6C0 /* HTMLDataElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLDataElement.cpp; sourceTree = "<group>"; };
 		8321507A1F27EA150095B136 /* NavigatorBeacon.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = NavigatorBeacon.cpp; sourceTree = "<group>"; };
 		8321507B1F27EA150095B136 /* NavigatorBeacon.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NavigatorBeacon.h; sourceTree = "<group>"; };
@@ -10803,6 +10809,9 @@
 		837A80121E1E127300026B9F /* English */ = {isa = PBXFileReference; lastKnownFileType = text.plist.stringsdict; name = English; path = English.lproj/Localizable.stringsdict; sourceTree = SOURCE_ROOT; };
 		837B7D1F1DC3F54C00D051FC /* ValidationBubbleIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ValidationBubbleIOS.mm; sourceTree = "<group>"; };
 		837DFB341EBFEA7000601385 /* ElementCSSInlineStyle.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ElementCSSInlineStyle.idl; sourceTree = "<group>"; };
+		837FB3401F9EA06600D0FC31 /* ExtendableMessageEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExtendableMessageEvent.h; sourceTree = "<group>"; };
+		837FB3421F9EA06700D0FC31 /* ExtendableMessageEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ExtendableMessageEvent.cpp; sourceTree = "<group>"; };
+		837FB3431F9EA06800D0FC31 /* ExtendableMessageEvent.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ExtendableMessageEvent.idl; sourceTree = "<group>"; };
 		8386A96C19F61B2E00E1EC4A /* StyleBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleBuilder.h; sourceTree = "<group>"; };
 		8386A96E19F61E4F00E1EC4A /* StyleBuilder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StyleBuilder.cpp; sourceTree = "<group>"; };
 		838867341D13BA59003697D0 /* RenderObjectEnums.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderObjectEnums.h; sourceTree = "<group>"; };
@@ -18179,6 +18188,8 @@
 				7E4C96D81AD4483500365A53 /* JSExtendableEvent.cpp */,
 				7E4C96D91AD4483500365A53 /* JSExtendableEvent.h */,
 				7E4C96D81AD4483500365A54 /* JSExtendableEventInit.cpp */,
+				83102B251F9EADC200E404B9 /* JSExtendableMessageEvent.cpp */,
+				83102B231F9EADC200E404B9 /* JSExtendableMessageEvent.h */,
 				7E4C96D81AD4483500365A52 /* JSFetchEvent.cpp */,
 				7E4C96D91AD4483500365A52 /* JSFetchEvent.h */,
 				51F886BE1F32920700C193EF /* JSNavigatorServiceWorker.cpp */,
@@ -18270,6 +18281,9 @@
 				41AF378E1F8C1E7C00111C31 /* ExtendableEvent.idl */,
 				4131F3B41F955BC30059995A /* ExtendableEventInit.h */,
 				4131F3B51F955BC50059995A /* ExtendableEventInit.idl */,
+				837FB3421F9EA06700D0FC31 /* ExtendableMessageEvent.cpp */,
+				837FB3401F9EA06600D0FC31 /* ExtendableMessageEvent.h */,
+				837FB3431F9EA06800D0FC31 /* ExtendableMessageEvent.idl */,
 				41AF37941F8DA49500111C31 /* FetchEvent.cpp */,
 				41AF37881F8C1E7900111C31 /* FetchEvent.h */,
 				41AF378D1F8C1E7B00111C31 /* FetchEvent.idl */,
@@ -19739,6 +19753,7 @@
 			isa = PBXGroup;
 			children = (
 				DEC2975D1B4DEB2A005F5945 /* JSCustomEventCustom.cpp */,
+				831C46C31F9EE5E000EBD450 /* JSExtendableMessageEventCustom.cpp */,
 				4131F3B11F9552810059995A /* JSFetchEventCustom.cpp */,
 				BCE7B1920D4E86960075A539 /* JSHistoryCustom.cpp */,
 				410B7E711045FAB000D8224F /* JSMessageEventCustom.cpp */,
@@ -27343,6 +27358,7 @@
 				935FBCF209BA143B00E230B1 /* ExceptionCode.h in Headers */,
 				51F645621F45398F00B54DED /* ExceptionData.h in Headers */,
 				93D196311D6CAB7600FC7E47 /* ExceptionOr.h in Headers */,
+				837FB3451F9EA06D00D0FC31 /* ExtendableMessageEvent.h in Headers */,
 				31DCDF441DA1C45400EA5B93 /* ExtendedColor.h in Headers */,
 				6E67D2A91280E8BD008758F7 /* Extensions3D.h in Headers */,
 				6E67D2A71280E8A4008758F7 /* Extensions3DOpenGL.h in Headers */,
@@ -28087,6 +28103,7 @@
 				46B63F6C1C6E8D19002E914B /* JSEventTargetCustom.h in Headers */,
 				724ED3321A3A8B2300F5F13C /* JSEXTBlendMinMax.h in Headers */,
 				7E4C96DD1AD4483500365A53 /* JSExtendableEvent.h in Headers */,
+				83102B271F9EADD900E404B9 /* JSExtendableMessageEvent.h in Headers */,
 				5C4304B6191AEF46000E2BC0 /* JSEXTShaderTextureLOD.h in Headers */,
 				7728698414FD9ADA00F484DC /* JSEXTTextureFilterAnisotropic.h in Headers */,
 				77D50FF61ED4D99B00DA4C87 /* JSFederatedCredential.h in Headers */,
@@ -31097,6 +31114,7 @@
 				262EC41D1D110B9000BA78FC /* EventTrackingRegions.cpp in Sources */,
 				724ED32C1A3A7E5400F5F13C /* EXTBlendMinMax.cpp in Sources */,
 				41AF37991F8DADAA00111C31 /* ExtendableEvent.cpp in Sources */,
+				837FB3441F9EA06D00D0FC31 /* ExtendableMessageEvent.cpp in Sources */,
 				31DCDF431DA1C45400EA5B93 /* ExtendedColor.cpp in Sources */,
 				6E67D2A61280E8A4008758F7 /* Extensions3DOpenGL.cpp in Sources */,
 				44DAB5B115A623580097C1E4 /* Extensions3DOpenGLCommon.cpp in Sources */,

Modified: trunk/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp (223921 => 223922)


--- trunk/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp	2017-10-24 21:17:17 UTC (rev 223921)
+++ trunk/Source/WebCore/bindings/js/JSBindingsAllInOne.cpp	2017-10-24 21:22:54 UTC (rev 223922)
@@ -62,6 +62,7 @@
 #include "JSEventCustom.cpp"
 #include "JSEventListener.cpp"
 #include "JSEventTargetCustom.cpp"
+#include "JSExtendableMessageEventCustom.cpp"
 #include "JSFileSystemEntryCustom.cpp"
 #include "JSHTMLCollectionCustom.cpp"
 #include "JSHTMLDocumentCustom.cpp"

Copied: trunk/Source/WebCore/bindings/js/JSExtendableMessageEventCustom.cpp (from rev 223921, trunk/Source/WebCore/workers/service/ServiceWorker.cpp) (0 => 223922)


--- trunk/Source/WebCore/bindings/js/JSExtendableMessageEventCustom.cpp	                        (rev 0)
+++ trunk/Source/WebCore/bindings/js/JSExtendableMessageEventCustom.cpp	2017-10-24 21:22:54 UTC (rev 223922)
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(SERVICE_WORKER)
+#include "JSExtendableMessageEvent.h"
+
+namespace WebCore {
+
+using namespace JSC;
+
+JSValue JSExtendableMessageEvent::data(ExecState& state) const
+{
+    if (JSValue cachedValue = m_data.get()) {
+        // We cannot use a cached object if we are in a different world than the one it was created in.
+        if (!cachedValue.isObject() || &worldForDOMObject(cachedValue.getObject()) == &currentWorld(&state))
+            return cachedValue;
+        ASSERT_NOT_REACHED();
+    }
+
+    auto& event = wrapped();
+    JSValue result;
+    if (auto* serializedValue = event.data())
+        result = serializedValue->deserialize(state, globalObject(), event.ports(), SerializationErrorMode::NonThrowing);
+    else
+        result = jsNull();
+
+    // Save the result so we don't have to deserialize the value again.
+    m_data.set(state.vm(), this, result);
+    return result;
+}
+
+}
+
+#endif // ENABLE(SERVICE_WORKER)

Modified: trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h (223921 => 223922)


--- trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h	2017-10-24 21:17:17 UTC (rev 223921)
+++ trunk/Source/WebCore/bindings/js/WebCoreBuiltinNames.h	2017-10-24 21:22:54 UTC (rev 223922)
@@ -49,6 +49,7 @@
     macro(DataTransferItemList) \
     macro(DocumentTimeline) \
     macro(ExtendableEvent) \
+    macro(ExtendableMessageEvent) \
     macro(FederatedCredential) \
     macro(FetchEvent) \
     macro(FileSystem) \

Modified: trunk/Source/WebCore/dom/Document.h (223921 => 223922)


--- trunk/Source/WebCore/dom/Document.h	2017-10-24 21:17:17 UTC (rev 223921)
+++ trunk/Source/WebCore/dom/Document.h	2017-10-24 21:22:54 UTC (rev 223922)
@@ -863,7 +863,7 @@
 
     WEBCORE_EXPORT String referrer() const;
 
-    WEBCORE_EXPORT String origin() const;
+    WEBCORE_EXPORT String origin() const final;
 
     WEBCORE_EXPORT String domain() const;
     ExceptionOr<void> setDomain(const String& newDomain);

Modified: trunk/Source/WebCore/dom/EventNames.in (223921 => 223922)


--- trunk/Source/WebCore/dom/EventNames.in	2017-10-24 21:17:17 UTC (rev 223921)
+++ trunk/Source/WebCore/dom/EventNames.in	2017-10-24 21:22:54 UTC (rev 223922)
@@ -11,6 +11,7 @@
 CompositionEvent
 CustomEvent
 ExtendableEvent conditional=SERVICE_WORKER
+ExtendableMessageEvent conditional=SERVICE_WORKER
 ErrorEvent
 FetchEvent conditional=SERVICE_WORKER
 FocusEvent

Modified: trunk/Source/WebCore/dom/MessagePortChannel.h (223921 => 223922)


--- trunk/Source/WebCore/dom/MessagePortChannel.h	2017-10-24 21:17:17 UTC (rev 223921)
+++ trunk/Source/WebCore/dom/MessagePortChannel.h	2017-10-24 21:22:54 UTC (rev 223922)
@@ -92,7 +92,7 @@
         // Returns the entangled port if run by the same thread (see MessagePort::locallyEntangledPort() for more details).
         MessagePort* locallyEntangledPort(const ScriptExecutionContext*);
 
-        ~MessagePortChannel();
+        WEBCORE_EXPORT ~MessagePortChannel();
 
     private:
         RefPtr<PlatformMessagePortChannel> m_channel;

Modified: trunk/Source/WebCore/dom/ScriptExecutionContext.h (223921 => 223922)


--- trunk/Source/WebCore/dom/ScriptExecutionContext.h	2017-10-24 21:17:17 UTC (rev 223921)
+++ trunk/Source/WebCore/dom/ScriptExecutionContext.h	2017-10-24 21:22:54 UTC (rev 223922)
@@ -111,6 +111,7 @@
     virtual void addConsoleMessage(MessageSource, MessageLevel, const String& message, unsigned long requestIdentifier = 0) = 0;
 
     virtual SecurityOrigin& topOrigin() const = 0;
+    virtual String origin() const = 0;
 
     virtual bool shouldBypassMainWorldContentSecurityPolicy() const { return false; }
 

Modified: trunk/Source/WebCore/workers/WorkerGlobalScope.h (223921 => 223922)


--- trunk/Source/WebCore/workers/WorkerGlobalScope.h	2017-10-24 21:17:17 UTC (rev 223921)
+++ trunk/Source/WebCore/workers/WorkerGlobalScope.h	2017-10-24 21:22:54 UTC (rev 223922)
@@ -63,7 +63,7 @@
     virtual bool isServiceWorkerGlobalScope() const { return false; }
 
     const URL& url() const final { return m_url; }
-    String origin() const;
+    String origin() const final;
 
 #if ENABLE(INDEXED_DATABASE)
     IDBClient::IDBConnectionProxy* idbConnectionProxy() final;

Modified: trunk/Source/WebCore/workers/service/ExtendableEvent.cpp (223921 => 223922)


--- trunk/Source/WebCore/workers/service/ExtendableEvent.cpp	2017-10-24 21:17:17 UTC (rev 223921)
+++ trunk/Source/WebCore/workers/service/ExtendableEvent.cpp	2017-10-24 21:22:54 UTC (rev 223922)
@@ -37,6 +37,15 @@
 {
 }
 
+ExtendableEvent::ExtendableEvent(const AtomicString& type, bool bubbles, bool cancelable)
+    : Event(type, bubbles, cancelable)
+{
+}
+
+ExtendableEvent::~ExtendableEvent()
+{
+}
+
 ExceptionOr<void> ExtendableEvent::waitUntil(Ref<DOMPromise>&& promise)
 {
     if (!isTrusted())

Modified: trunk/Source/WebCore/workers/service/ExtendableEvent.h (223921 => 223922)


--- trunk/Source/WebCore/workers/service/ExtendableEvent.h	2017-10-24 21:17:17 UTC (rev 223921)
+++ trunk/Source/WebCore/workers/service/ExtendableEvent.h	2017-10-24 21:22:54 UTC (rev 223922)
@@ -42,6 +42,8 @@
         return adoptRef(*new ExtendableEvent(type, initializer, isTrusted));
     }
 
+    ~ExtendableEvent();
+
     EventInterface eventInterface() const override { return ExtendableEventInterfaceType; }
 
     ExceptionOr<void> waitUntil(Ref<DOMPromise>&&);
@@ -50,6 +52,7 @@
 
 protected:
     WEBCORE_EXPORT ExtendableEvent(const AtomicString&, const ExtendableEventInit&, IsTrusted);
+    ExtendableEvent(const AtomicString&, bool bubbles, bool cancelable);
 
     WeakPtr<ExtendableEvent> createWeakPtr() { return m_weakPtrFactory.createWeakPtr(*this); }
 

Copied: trunk/Source/WebCore/workers/service/ExtendableMessageEvent.cpp (from rev 223921, trunk/Source/WebCore/workers/service/ServiceWorker.cpp) (0 => 223922)


--- trunk/Source/WebCore/workers/service/ExtendableMessageEvent.cpp	                        (rev 0)
+++ trunk/Source/WebCore/workers/service/ExtendableMessageEvent.cpp	2017-10-24 21:22:54 UTC (rev 223922)
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#if ENABLE(SERVICE_WORKER)
+#include "ExtendableMessageEvent.h"
+
+#include "EventNames.h"
+
+namespace WebCore {
+
+Ref<ExtendableMessageEvent> ExtendableMessageEvent::create(Vector<RefPtr<MessagePort>>&& ports, RefPtr<SerializedScriptValue>&& data, const String& origin, const String& lastEventId, std::optional<ExtendableMessageEventSource>&& source)
+{
+    return adoptRef(*new ExtendableMessageEvent(WTFMove(data), origin, lastEventId, WTFMove(source), WTFMove(ports)));
+}
+
+ExtendableMessageEvent::ExtendableMessageEvent(JSC::ExecState& state, const AtomicString& type, const Init& init, IsTrusted isTrusted)
+    : ExtendableEvent(type, init, isTrusted)
+    , m_data(SerializedScriptValue::create(state, init.data))
+    , m_origin(init.origin)
+    , m_lastEventId(init.lastEventId)
+    , m_ports(init.ports)
+{
+}
+
+ExtendableMessageEvent::ExtendableMessageEvent(RefPtr<SerializedScriptValue>&& data, const String& origin, const String& lastEventId, std::optional<ExtendableMessageEventSource>&& source, Vector<RefPtr<MessagePort>>&& ports)
+    : ExtendableEvent(eventNames().messageEvent, false, false)
+    , m_data(WTFMove(data))
+    , m_origin(origin)
+    , m_lastEventId(lastEventId)
+    , m_source(WTFMove(source))
+    , m_ports(WTFMove(ports))
+{
+}
+
+ExtendableMessageEvent::~ExtendableMessageEvent()
+{
+}
+
+} // namespace WebCore
+
+#endif // ENABLE(SERVICE_WORKER)

Added: trunk/Source/WebCore/workers/service/ExtendableMessageEvent.h (0 => 223922)


--- trunk/Source/WebCore/workers/service/ExtendableMessageEvent.h	                        (rev 0)
+++ trunk/Source/WebCore/workers/service/ExtendableMessageEvent.h	2017-10-24 21:22:54 UTC (rev 223922)
@@ -0,0 +1,90 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(SERVICE_WORKER)
+
+#include "ExtendableEvent.h"
+#include "ExtendableEventInit.h"
+#include "MessagePort.h"
+#include "ServiceWorker.h"
+#include "ServiceWorkerClient.h"
+#include <wtf/Variant.h>
+
+namespace JSC {
+class ExecState;
+class JSValue;
+}
+
+namespace WebCore {
+
+class MessagePort;
+class ServiceWorker;
+class ServiceWorkerClient;
+
+using ExtendableMessageEventSource = Variant<RefPtr<ServiceWorkerClient>, RefPtr<ServiceWorker>, RefPtr<MessagePort>>;
+
+class ExtendableMessageEvent final : public ExtendableEvent {
+public:
+    struct Init : ExtendableEventInit {
+        JSC::JSValue data;
+        String origin;
+        String lastEventId;
+        std::optional<ExtendableMessageEventSource> source;
+        Vector<RefPtr<MessagePort>> ports;
+    };
+
+    static Ref<ExtendableMessageEvent> create(JSC::ExecState& state, const AtomicString& type, const Init& initializer, IsTrusted isTrusted = IsTrusted::No)
+    {
+        return adoptRef(*new ExtendableMessageEvent(state, type, initializer, isTrusted));
+    }
+
+    static Ref<ExtendableMessageEvent> create(Vector<RefPtr<MessagePort>>&&, RefPtr<SerializedScriptValue>&&, const String& origin = { }, const String& lastEventId = { }, std::optional<ExtendableMessageEventSource>&& source = std::nullopt);
+
+    ~ExtendableMessageEvent();
+
+    SerializedScriptValue* data() const { return m_data.get(); }
+    const String& origin() const { return m_origin; }
+    const String& lastEventId() const { return m_lastEventId; }
+    const std::optional<ExtendableMessageEventSource>& source() const { return m_source; }
+    const Vector<RefPtr<MessagePort>>& ports() const { return m_ports; }
+
+    EventInterface eventInterface() const final { return ExtendableMessageEventInterfaceType; }
+
+private:
+    ExtendableMessageEvent(JSC::ExecState&, const AtomicString&, const Init&, IsTrusted);
+    ExtendableMessageEvent(RefPtr<SerializedScriptValue>&& data, const String& origin, const String& lastEventId, std::optional<ExtendableMessageEventSource>&&, Vector<RefPtr<MessagePort>>&&);
+
+    RefPtr<SerializedScriptValue> m_data;
+    String m_origin;
+    String m_lastEventId;
+    std::optional<ExtendableMessageEventSource> m_source;
+    Vector<RefPtr<MessagePort>> m_ports;
+};
+
+} // namespace WebCore
+
+#endif // ENABLE(SERVICE_WORKER)

Copied: trunk/Source/WebCore/workers/service/ExtendableMessageEvent.idl (from rev 223921, trunk/Source/WebCore/workers/service/ServiceWorker.idl) (0 => 223922)


--- trunk/Source/WebCore/workers/service/ExtendableMessageEvent.idl	                        (rev 0)
+++ trunk/Source/WebCore/workers/service/ExtendableMessageEvent.idl	2017-10-24 21:22:54 UTC (rev 223922)
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+[
+    Constructor(DOMString type, optional ExtendableMessageEventInit eventInitDict),
+    ConstructorCallWith=ScriptState,
+    Conditional=SERVICE_WORKER,
+    EnabledAtRuntime=ServiceWorker,
+    Exposed=ServiceWorker,
+] interface ExtendableMessageEvent : ExtendableEvent {
+    [CachedAttribute, CustomGetter] readonly attribute any data;
+    readonly attribute USVString origin;
+    readonly attribute DOMString lastEventId;
+    [SameObject] readonly attribute (ServiceWorkerClient or ServiceWorker or MessagePort)? source;
+    readonly attribute FrozenArray<MessagePort> ports;
+};
+
+dictionary ExtendableMessageEventInit : ExtendableEventInit {
+    any data = ""
+    USVString origin = "";
+    DOMString lastEventId = "";
+    (ServiceWorkerClient or ServiceWorker or MessagePort)? source = null;
+    sequence<MessagePort> ports = [];
+};

Modified: trunk/Source/WebCore/workers/service/ServiceWorker.cpp (223921 => 223922)


--- trunk/Source/WebCore/workers/service/ServiceWorker.cpp	2017-10-24 21:17:17 UTC (rev 223921)
+++ trunk/Source/WebCore/workers/service/ServiceWorker.cpp	2017-10-24 21:22:54 UTC (rev 223922)
@@ -28,10 +28,49 @@
 
 #if ENABLE(SERVICE_WORKER)
 
+#include "MessagePort.h"
+#include "SWClientConnection.h"
+#include "ScriptExecutionContext.h"
+#include "SerializedScriptValue.h"
+#include "ServiceWorkerProvider.h"
+#include <runtime/JSCJSValueInlines.h>
+
 namespace WebCore {
 
-ExceptionOr<void> ServiceWorker::postMessage(JSC::ExecState&, JSC::JSValue, Vector<JSC::Strong<JSC::JSObject>>&&)
+ServiceWorker::ServiceWorker(ScriptExecutionContext& context, uint64_t serviceWorkerIdentifier)
+    : ContextDestructionObserver(&context)
+    , m_identifier(serviceWorkerIdentifier)
 {
+}
+
+ExceptionOr<void> ServiceWorker::postMessage(ScriptExecutionContext& context, JSC::JSValue messageValue, Vector<JSC::Strong<JSC::JSObject>>&& transfer)
+{
+    if (state() == State::Redundant)
+        return Exception { InvalidStateError, ASCIILiteral("Service Worker state is redundant") };
+
+    // FIXME: Invoke Run Service Worker algorithm with serviceWorker as the argument.
+
+    auto* execState = context.execState();
+    ASSERT(execState);
+
+    Vector<RefPtr<MessagePort>> ports;
+    auto message = SerializedScriptValue::create(*execState, messageValue, WTFMove(transfer), ports, SerializationContext::WorkerPostMessage);
+    if (message.hasException())
+        return message.releaseException();
+
+    // Disentangle the port in preparation for sending it to the remote context.
+    auto channelsOrException = MessagePort::disentanglePorts(WTFMove(ports));
+    if (channelsOrException.hasException())
+        return channelsOrException.releaseException();
+
+    // FIXME: Support sending the channels.
+    auto channels = channelsOrException.releaseReturnValue();
+    if (channels && !channels->isEmpty())
+        return Exception { NotSupportedError, ASCIILiteral("Passing MessagePort objects to postMessage is not yet supported") };
+
+    auto& swConnection = ServiceWorkerProvider::singleton().serviceWorkerConnectionForSession(context.sessionID());
+    swConnection.postMessageToServiceWorkerGlobalScope(m_identifier, message.releaseReturnValue(), context.origin());
+
     return { };
 }
 
@@ -42,7 +81,7 @@
 
 ServiceWorker::State ServiceWorker::state() const
 {
-    return State::Redundant;
+    return State::Activated;
 }
 
 EventTargetInterface ServiceWorker::eventTargetInterface() const
@@ -52,7 +91,7 @@
 
 ScriptExecutionContext* ServiceWorker::scriptExecutionContext() const
 {
-    return nullptr;
+    return ContextDestructionObserver::scriptExecutionContext();
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/workers/service/ServiceWorker.h (223921 => 223922)


--- trunk/Source/WebCore/workers/service/ServiceWorker.h	2017-10-24 21:17:17 UTC (rev 223921)
+++ trunk/Source/WebCore/workers/service/ServiceWorker.h	2017-10-24 21:22:54 UTC (rev 223922)
@@ -27,11 +27,12 @@
 
 #if ENABLE(SERVICE_WORKER)
 
+#include "ContextDestructionObserver.h"
 #include "EventTarget.h"
 #include <heap/Strong.h>
+#include <wtf/RefCounted.h>
 
 namespace JSC {
-class ExecState;
 class JSValue;
 }
 
@@ -39,9 +40,13 @@
 
 class Frame;
 
-class ServiceWorker final : public EventTargetWithInlineData {
+class ServiceWorker final : public RefCounted<ServiceWorker>, public EventTargetWithInlineData, public ContextDestructionObserver {
 public:
-    static Ref<ServiceWorker> create(Frame& frame) { return adoptRef(*new ServiceWorker(frame)); }
+    static Ref<ServiceWorker> create(ScriptExecutionContext& context, uint64_t serviceWorkerIdentifier)
+    {
+        return adoptRef(*new ServiceWorker(context, serviceWorkerIdentifier));
+    }
+
     virtual ~ServiceWorker() = default;
 
     enum class State {
@@ -55,15 +60,22 @@
     const String& scriptURL() const;
     State state() const;
 
-    ExceptionOr<void> postMessage(JSC::ExecState&, JSC::JSValue message, Vector<JSC::Strong<JSC::JSObject>>&&);
+    ExceptionOr<void> postMessage(ScriptExecutionContext&, JSC::JSValue message, Vector<JSC::Strong<JSC::JSObject>>&&);
 
+    uint64_t identifier() const { return m_identifier; }
+
+    using RefCounted::ref;
+    using RefCounted::deref;
+
 private:
-    explicit ServiceWorker(Frame&);
+    ServiceWorker(ScriptExecutionContext&, uint64_t serviceWorkerIdentifier);
 
     virtual EventTargetInterface eventTargetInterface() const;
     virtual ScriptExecutionContext* scriptExecutionContext() const;
     void refEventTarget() final { ref(); }
     void derefEventTarget() final { deref(); }
+
+    uint64_t m_identifier;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/workers/service/ServiceWorker.idl (223921 => 223922)


--- trunk/Source/WebCore/workers/service/ServiceWorker.idl	2017-10-24 21:17:17 UTC (rev 223921)
+++ trunk/Source/WebCore/workers/service/ServiceWorker.idl	2017-10-24 21:22:54 UTC (rev 223922)
@@ -34,7 +34,7 @@
 ] interface ServiceWorker : EventTarget {
     readonly attribute USVString scriptURL;
     readonly attribute ServiceWorkerState state;
-    [CallWith=ScriptState, MayThrowException] void postMessage(any message, optional sequence<object> transfer = []);
+    [CallWith=ScriptExecutionContext, MayThrowException] void postMessage(any message, optional sequence<object> transfer = []);
 
     // event
     attribute EventHandler onstatechange;

Modified: trunk/Source/WebCore/workers/service/ServiceWorkerContainer.cpp (223921 => 223922)


--- trunk/Source/WebCore/workers/service/ServiceWorkerContainer.cpp	2017-10-24 21:17:17 UTC (rev 223921)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerContainer.cpp	2017-10-24 21:22:54 UTC (rev 223922)
@@ -38,6 +38,7 @@
 #include "ScopeGuard.h"
 #include "ScriptExecutionContext.h"
 #include "SecurityOrigin.h"
+#include "ServiceWorker.h"
 #include "ServiceWorkerJob.h"
 #include "ServiceWorkerJobData.h"
 #include "ServiceWorkerProvider.h"
@@ -74,7 +75,14 @@
 
 ServiceWorker* ServiceWorkerContainer::controller() const
 {
-    return nullptr;
+    auto* context = scriptExecutionContext();
+    if (!context || !context->selectedServiceWorkerIdentifier()) {
+        m_controller = nullptr;
+        return nullptr;
+    }
+    if (!m_controller || m_controller->identifier() != context->selectedServiceWorkerIdentifier())
+        m_controller = ServiceWorker::create(*context, context->selectedServiceWorkerIdentifier());
+    return m_controller.get();
 }
 
 void ServiceWorkerContainer::addRegistration(const String& relativeScriptURL, const RegistrationOptions& options, Ref<DeferredPromise>&& promise)

Modified: trunk/Source/WebCore/workers/service/ServiceWorkerContainer.h (223921 => 223922)


--- trunk/Source/WebCore/workers/service/ServiceWorkerContainer.h	2017-10-24 21:17:17 UTC (rev 223921)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerContainer.h	2017-10-24 21:22:54 UTC (rev 223922)
@@ -94,6 +94,7 @@
 
     RefPtr<SWClientConnection> m_swConnection;
     HashMap<uint64_t, RefPtr<ServiceWorkerJob>> m_jobMap;
+    mutable RefPtr<ServiceWorker> m_controller;
 
 #ifndef NDEBUG
     ThreadIdentifier m_creationThread { currentThread() };

Modified: trunk/Source/WebCore/workers/service/ServiceWorkerGlobalScope.cpp (223921 => 223922)


--- trunk/Source/WebCore/workers/service/ServiceWorkerGlobalScope.cpp	2017-10-24 21:17:17 UTC (rev 223921)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerGlobalScope.cpp	2017-10-24 21:22:54 UTC (rev 223922)
@@ -58,6 +58,11 @@
     return ServiceWorkerGlobalScopeEventTargetInterfaceType;
 }
 
+ServiceWorkerThread& ServiceWorkerGlobalScope::thread()
+{
+    return static_cast<ServiceWorkerThread&>(WorkerGlobalScope::thread());
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(SERVICE_WORKER)

Modified: trunk/Source/WebCore/workers/service/ServiceWorkerGlobalScope.h (223921 => 223922)


--- trunk/Source/WebCore/workers/service/ServiceWorkerGlobalScope.h	2017-10-24 21:17:17 UTC (rev 223921)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerGlobalScope.h	2017-10-24 21:22:54 UTC (rev 223922)
@@ -57,6 +57,8 @@
 
     EventTargetInterface eventTargetInterface() const final;
 
+    ServiceWorkerThread& thread();
+
 private:
     ServiceWorkerGlobalScope(uint64_t serverConnectionIdentifier, const ServiceWorkerContextData&, const URL&, const String& identifier, const String& userAgent, ServiceWorkerThread&, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, IDBClient::IDBConnectionProxy*, SocketProvider*, PAL::SessionID);
 
@@ -67,4 +69,9 @@
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::ServiceWorkerGlobalScope)
+    static bool isType(const WebCore::ScriptExecutionContext& context) { return is<WebCore::WorkerGlobalScope>(context) && downcast<WebCore::WorkerGlobalScope>(context).isServiceWorkerGlobalScope(); }
+    static bool isType(const WebCore::WorkerGlobalScope& context) { return context.isServiceWorkerGlobalScope(); }
+SPECIALIZE_TYPE_TRAITS_END()
+
 #endif // ENABLE(SERVICE_WORKER)

Modified: trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.cpp (223921 => 223922)


--- trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.cpp	2017-10-24 21:17:17 UTC (rev 223921)
+++ trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.cpp	2017-10-24 21:22:54 UTC (rev 223922)
@@ -29,6 +29,7 @@
 #if ENABLE(SERVICE_WORKER)
 
 #include "ContentSecurityPolicyResponseHeaders.h"
+#include "ExtendableMessageEvent.h"
 #include "SecurityOrigin.h"
 #include "ServiceWorkerFetch.h"
 #include "ServiceWorkerGlobalScope.h"
@@ -100,6 +101,17 @@
     }, WorkerRunLoop::defaultMode());
 }
 
+void ServiceWorkerThread::postMessageToServiceWorkerGlobalScope(Ref<SerializedScriptValue>&& message, std::unique_ptr<MessagePortChannelArray>&& channels, const String& sourceOrigin)
+{
+    ScriptExecutionContext::Task task([channels = WTFMove(channels), message = WTFMove(message), sourceOrigin = sourceOrigin.isolatedCopy()] (ScriptExecutionContext& context) mutable {
+        auto& serviceWorkerGlobalScope = downcast<ServiceWorkerGlobalScope>(context);
+        auto ports = MessagePort::entanglePorts(serviceWorkerGlobalScope, WTFMove(channels));
+        serviceWorkerGlobalScope.dispatchEvent(ExtendableMessageEvent::create(WTFMove(ports), WTFMove(message), sourceOrigin));
+        serviceWorkerGlobalScope.thread().workerObjectProxy().confirmMessageFromWorkerObject(serviceWorkerGlobalScope.hasPendingActivity());
+    });
+    runLoop().postTask(WTFMove(task));
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(SERVICE_WORKER)

Modified: trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.h (223921 => 223922)


--- trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.h	2017-10-24 21:17:17 UTC (rev 223921)
+++ trunk/Source/WebCore/workers/service/context/ServiceWorkerThread.h	2017-10-24 21:22:54 UTC (rev 223922)
@@ -35,9 +35,13 @@
 namespace WebCore {
 
 class ContentSecurityPolicyResponseHeaders;
+class MessagePortChannel;
+class SerializedScriptValue;
 class WorkerObjectProxy;
 struct ServiceWorkerContextData;
 
+using MessagePortChannelArray = Vector<std::unique_ptr<MessagePortChannel>, 1>;
+
 class ServiceWorkerThread : public WorkerThread, public ThreadSafeIdentified<ServiceWorkerThread> {
 public:
     template<typename... Args> static Ref<ServiceWorkerThread> create(Args&&... args)
@@ -49,6 +53,7 @@
     WorkerObjectProxy& workerObjectProxy() const { return m_workerObjectProxy; }
 
     WEBCORE_EXPORT void postFetchTask(Ref<ServiceWorkerFetch::Client>&&, ResourceRequest&&, FetchOptions&&);
+    WEBCORE_EXPORT void postMessageToServiceWorkerGlobalScope(Ref<SerializedScriptValue>&&, std::unique_ptr<MessagePortChannelArray>&&, const String& sourceOrigin);
 
 protected:
     Ref<WorkerGlobalScope> createWorkerGlobalScope(const URL&, const String& identifier, const String& userAgent, const ContentSecurityPolicyResponseHeaders&, bool shouldBypassMainWorldContentSecurityPolicy, Ref<SecurityOrigin>&& topOrigin, MonotonicTime timeOrigin, PAL::SessionID) final;

Modified: trunk/Source/WebCore/workers/service/server/SWClientConnection.h (223921 => 223922)


--- trunk/Source/WebCore/workers/service/server/SWClientConnection.h	2017-10-24 21:17:17 UTC (rev 223921)
+++ trunk/Source/WebCore/workers/service/server/SWClientConnection.h	2017-10-24 21:22:54 UTC (rev 223922)
@@ -35,6 +35,7 @@
 
 class ResourceError;
 class SecurityOrigin;
+class SerializedScriptValue;
 class SharedBuffer;
 struct ExceptionData;
 struct ServiceWorkerFetchResult;
@@ -48,6 +49,7 @@
     void scheduleJob(ServiceWorkerJob&);
     void finishedFetchingScript(ServiceWorkerJob&, const String&);
     void failedFetchingScript(ServiceWorkerJob&, const ResourceError&);
+    virtual void postMessageToServiceWorkerGlobalScope(uint64_t serviceWorkerIdentifier, Ref<SerializedScriptValue>&&, const String& sourceOrigin) = 0;
 
     virtual uint64_t identifier() const = 0;
     virtual bool hasServiceWorkerRegisteredForOrigin(const SecurityOrigin&) const = 0;

Modified: trunk/Source/WebKit/ChangeLog (223921 => 223922)


--- trunk/Source/WebKit/ChangeLog	2017-10-24 21:17:17 UTC (rev 223921)
+++ trunk/Source/WebKit/ChangeLog	2017-10-24 21:22:54 UTC (rev 223922)
@@ -1,3 +1,25 @@
+2017-10-24  Chris Dumez  <cdu...@apple.com>
+
+        Add initial implementation for serviceWorker.postMessage()
+        https://bugs.webkit.org/show_bug.cgi?id=178534
+
+        Reviewed by Youenn Fablet.
+
+        Add initial implementation for serviceWorker.postMessage():
+        - https://w3c.github.io/ServiceWorker/#service-worker-postmessage
+
+        * StorageProcess/ServiceWorker/WebSWServerConnection.cpp:
+        (WebKit::WebSWServerConnection::postMessageToServiceWorkerGlobalScope):
+        * StorageProcess/ServiceWorker/WebSWServerConnection.h:
+        * StorageProcess/ServiceWorker/WebSWServerConnection.messages.in:
+        * WebProcess/Storage/ServiceWorkerContextManager.cpp:
+        (WebKit::ServiceWorkerContextManager::postMessageToServiceWorkerGlobalScope):
+        * WebProcess/Storage/ServiceWorkerContextManager.h:
+        * WebProcess/Storage/ServiceWorkerContextManager.messages.in:
+        * WebProcess/Storage/WebSWClientConnection.cpp:
+        (WebKit::WebSWClientConnection::postMessageToServiceWorkerGlobalScope):
+        * WebProcess/Storage/WebSWClientConnection.h:
+
 2017-10-24  Brent Fulgham  <bfulg...@apple.com>
 
         Adopt new secure coding APIs

Modified: trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp (223921 => 223922)


--- trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp	2017-10-24 21:17:17 UTC (rev 223921)
+++ trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.cpp	2017-10-24 21:22:54 UTC (rev 223922)
@@ -100,6 +100,11 @@
     sendToContextProcess(Messages::ServiceWorkerContextManager::StartFetch(identifier(), fetchIdentifier, serviceWorkerIdentifier, request, options));
 }
 
+void WebSWServerConnection::postMessageToServiceWorkerGlobalScope(uint64_t serviceWorkerIdentifier, const IPC::DataReference& message, const String& sourceOrigin)
+{
+    sendToContextProcess(Messages::ServiceWorkerContextManager::PostMessageToServiceWorkerGlobalScope(identifier(), serviceWorkerIdentifier, message, sourceOrigin));
+}
+
 void WebSWServerConnection::didReceiveFetchResponse(uint64_t fetchIdentifier, const ResourceResponse& response)
 {
     m_contentConnection->send(Messages::ServiceWorkerClientFetch::DidReceiveResponse { response }, fetchIdentifier);

Modified: trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h (223921 => 223922)


--- trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h	2017-10-24 21:17:17 UTC (rev 223921)
+++ trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.h	2017-10-24 21:22:54 UTC (rev 223922)
@@ -65,6 +65,8 @@
 
     void startFetch(uint64_t fetchIdentifier, uint64_t serviceWorkerIdentifier, const WebCore::ResourceRequest&, const WebCore::FetchOptions&);
 
+    void postMessageToServiceWorkerGlobalScope(uint64_t serviceWorkerIdentifier, const IPC::DataReference& message, const String& sourceOrigin);
+
     // Messages to the SW context WebProcess
     void startServiceWorkerContext(const WebCore::ServiceWorkerContextData&) final;
 

Modified: trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.messages.in (223921 => 223922)


--- trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.messages.in	2017-10-24 21:17:17 UTC (rev 223921)
+++ trunk/Source/WebKit/StorageProcess/ServiceWorker/WebSWServerConnection.messages.in	2017-10-24 21:22:54 UTC (rev 223922)
@@ -28,6 +28,7 @@
     FinishFetchingScriptInServer(struct WebCore::ServiceWorkerFetchResult result)
 
     StartFetch(uint64_t identifier, uint64_t serviceWorkerIdentifier, WebCore::ResourceRequest request, struct WebCore::FetchOptions options)
+    PostMessageToServiceWorkerGlobalScope(uint64_t serviceWorkerIdentifier, IPC::DataReference message, String sourceOrigin)
 }
 
 #endif // ENABLE(SERVICE_WORKER)

Modified: trunk/Source/WebKit/WebProcess/Storage/ServiceWorkerContextManager.cpp (223921 => 223922)


--- trunk/Source/WebKit/WebProcess/Storage/ServiceWorkerContextManager.cpp	2017-10-24 21:17:17 UTC (rev 223921)
+++ trunk/Source/WebKit/WebProcess/Storage/ServiceWorkerContextManager.cpp	2017-10-24 21:22:54 UTC (rev 223922)
@@ -28,12 +28,15 @@
 
 #if ENABLE(SERVICE_WORKER)
 
+#include "DataReference.h"
 #include "Logging.h"
 #include "StorageProcessMessages.h"
 #include "WebCoreArgumentCoders.h"
 #include "WebServiceWorkerFetchTaskClient.h"
+#include <WebCore/MessagePortChannel.h>
 #include <WebCore/ResourceRequest.h>
 #include <WebCore/ResourceResponse.h>
+#include <WebCore/SerializedScriptValue.h>
 #include <pal/SessionID.h>
 
 using namespace PAL;
@@ -68,6 +71,16 @@
     serviceWorkerThread->postFetchTask(WTFMove(client), WTFMove(request), WTFMove(options));
 }
 
+void ServiceWorkerContextManager::postMessageToServiceWorkerGlobalScope(uint64_t serverConnectionIdentifier, uint64_t serviceWorkerIdentifier, const IPC::DataReference& message, const String& sourceOrigin)
+{
+    auto* workerThread = m_workerThreadMap.get(serviceWorkerIdentifier);
+    if (!workerThread)
+        return;
+
+    // FIXME: We should pass valid MessagePortChannels.
+    workerThread->postMessageToServiceWorkerGlobalScope(SerializedScriptValue::adopt(message.vector()), nullptr, sourceOrigin);
+}
+
 } // namespace WebCore
 
 #endif // ENABLE(SERVICE_WORKER)

Modified: trunk/Source/WebKit/WebProcess/Storage/ServiceWorkerContextManager.h (223921 => 223922)


--- trunk/Source/WebKit/WebProcess/Storage/ServiceWorkerContextManager.h	2017-10-24 21:17:17 UTC (rev 223921)
+++ trunk/Source/WebKit/WebProcess/Storage/ServiceWorkerContextManager.h	2017-10-24 21:22:54 UTC (rev 223922)
@@ -52,6 +52,7 @@
 private:
     void startServiceWorker(uint64_t serverConnectionIdentifier, const WebCore::ServiceWorkerContextData&);
     void startFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, uint64_t serviceWorkerIdentifier, WebCore::ResourceRequest&&, WebCore::FetchOptions&&);
+    void postMessageToServiceWorkerGlobalScope(uint64_t serverConnectionIdentifier, uint64_t serviceWorkerIdentifier, const IPC::DataReference& message, const String& sourceOrigin);
 
     Ref<IPC::Connection> m_connectionToStorageProcess;
     HashMap<uint64_t, RefPtr<WebCore::ServiceWorkerThread>> m_workerThreadMap;

Modified: trunk/Source/WebKit/WebProcess/Storage/ServiceWorkerContextManager.messages.in (223921 => 223922)


--- trunk/Source/WebKit/WebProcess/Storage/ServiceWorkerContextManager.messages.in	2017-10-24 21:17:17 UTC (rev 223921)
+++ trunk/Source/WebKit/WebProcess/Storage/ServiceWorkerContextManager.messages.in	2017-10-24 21:22:54 UTC (rev 223922)
@@ -25,6 +25,7 @@
 messages -> ServiceWorkerContextManager {
     StartServiceWorker(uint64_t serverConnectionIdentifier, struct WebCore::ServiceWorkerContextData contextData)
     StartFetch(uint64_t serverConnectionIdentifier, uint64_t fetchIdentifier, uint64_t serviceWorkerIdentifier, WebCore::ResourceRequest request, struct WebCore::FetchOptions options)
+    PostMessageToServiceWorkerGlobalScope(uint64_t serverConnectionIdentifier, uint64_t serviceWorkerIdentifier, IPC::DataReference message, String sourceOrigin)
 }
 
 #endif

Modified: trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp (223921 => 223922)


--- trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp	2017-10-24 21:17:17 UTC (rev 223921)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.cpp	2017-10-24 21:22:54 UTC (rev 223922)
@@ -28,6 +28,7 @@
 
 #if ENABLE(SERVICE_WORKER)
 
+#include "DataReference.h"
 #include "Logging.h"
 #include "ServiceWorkerClientFetch.h"
 #include "StorageToWebProcessConnectionMessages.h"
@@ -34,6 +35,7 @@
 #include "WebCoreArgumentCoders.h"
 #include "WebSWOriginTable.h"
 #include "WebSWServerConnectionMessages.h"
+#include <WebCore/SerializedScriptValue.h>
 #include <WebCore/ServiceWorkerFetchResult.h>
 #include <WebCore/ServiceWorkerJobData.h>
 
@@ -66,6 +68,11 @@
     send(Messages::WebSWServerConnection::FinishFetchingScriptInServer(result));
 }
 
+void WebSWClientConnection::postMessageToServiceWorkerGlobalScope(uint64_t serviceWorkerIdentifier, Ref<SerializedScriptValue>&& scriptValue, const String& sourceOrigin)
+{
+    send(Messages::WebSWServerConnection::PostMessageToServiceWorkerGlobalScope(serviceWorkerIdentifier, IPC::DataReference { scriptValue->data() }, sourceOrigin));
+}
+
 bool WebSWClientConnection::hasServiceWorkerRegisteredForOrigin(const SecurityOrigin& origin) const
 {
     return m_swOriginTable->contains(origin);

Modified: trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.h (223921 => 223922)


--- trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.h	2017-10-24 21:17:17 UTC (rev 223921)
+++ trunk/Source/WebKit/WebProcess/Storage/WebSWClientConnection.h	2017-10-24 21:22:54 UTC (rev 223922)
@@ -56,6 +56,7 @@
 
     void scheduleJobInServer(const WebCore::ServiceWorkerJobData&) final;
     void finishFetchingScriptInServer(const WebCore::ServiceWorkerFetchResult&) final;
+    void postMessageToServiceWorkerGlobalScope(uint64_t serviceWorkerIdentifier, Ref<WebCore::SerializedScriptValue>&&, const String& sourceOrigin) final;
 
     void disconnectedFromWebProcess();
     void didReceiveMessage(IPC::Connection&, IPC::Decoder&) final;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to