Diff
Modified: trunk/LayoutTests/ChangeLog (225220 => 225221)
--- trunk/LayoutTests/ChangeLog 2017-11-28 17:39:17 UTC (rev 225220)
+++ trunk/LayoutTests/ChangeLog 2017-11-28 18:22:20 UTC (rev 225221)
@@ -1,3 +1,16 @@
+2017-11-28 Chris Dumez <[email protected]>
+
+ Start exposing navigator.serviceWorker inside service workers
+ https://bugs.webkit.org/show_bug.cgi?id=180087
+
+ Reviewed by Brady Eidson.
+
+ Add layout test coverage.
+
+ * http/tests/workers/service/WorkerNavigator_serviceWorker-expected.txt: Added.
+ * http/tests/workers/service/WorkerNavigator_serviceWorker.html: Added.
+ * http/tests/workers/service/resources/WorkerNavigator_serviceWorker-worker.js: Added.
+
2017-11-28 Michael Catanzaro <[email protected]>
REGRESSION(r225098): [WPE] Some features have changed of value (70 new failures)
Added: trunk/LayoutTests/http/tests/workers/service/WorkerNavigator_serviceWorker-expected.txt (0 => 225221)
--- trunk/LayoutTests/http/tests/workers/service/WorkerNavigator_serviceWorker-expected.txt (rev 0)
+++ trunk/LayoutTests/http/tests/workers/service/WorkerNavigator_serviceWorker-expected.txt 2017-11-28 18:22:20 UTC (rev 225221)
@@ -0,0 +1,13 @@
+* Tests that workerNavigator.serviceWorker exists
+
+Object.getOwnPropertyDescriptor(self.navigator.__proto__, 'serviceWorker') returned {"enumerable":true,"configurable":true}
+navigator.serviceWorker.__proto__ === self.ServiceWorkerContainer.prototype returned true
+navigator.serviceWorker.controller === null returned true
+Object.getOwnPropertyDescriptor(self, 'ServiceWorkerContainer') returned {"writable":true,"enumerable":false,"configurable":true}
+Object.getOwnPropertyDescriptor(self, 'ServiceWorker') returned {"writable":true,"enumerable":false,"configurable":true}
+Object.getOwnPropertyDescriptor(self, 'ServiceWorkerRegistration') returned {"writable":true,"enumerable":false,"configurable":true}
+Object.getOwnPropertyDescriptor(self.navigator.serviceWorker.__proto__, 'controller') returned {"enumerable":true,"configurable":true}
+Object.getOwnPropertyDescriptor(self.navigator.serviceWorker.__proto__, 'register') returned {"writable":true,"enumerable":true,"configurable":true}
+Object.getOwnPropertyDescriptor(self.navigator.serviceWorker.__proto__, 'getRegistration') returned {"writable":true,"enumerable":true,"configurable":true}
+Object.getOwnPropertyDescriptor(self.navigator.serviceWorker.__proto__, 'getRegistrations') returned {"writable":true,"enumerable":true,"configurable":true}
+
Added: trunk/LayoutTests/http/tests/workers/service/WorkerNavigator_serviceWorker.html (0 => 225221)
--- trunk/LayoutTests/http/tests/workers/service/WorkerNavigator_serviceWorker.html (rev 0)
+++ trunk/LayoutTests/http/tests/workers/service/WorkerNavigator_serviceWorker.html 2017-11-28 18:22:20 UTC (rev 225221)
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<script>
+log("* Tests that workerNavigator.serviceWorker exists");
+log("");
+
+navigator.serviceWorker.addEventListener("message", function(event) {
+ if (event.data ="" "DONE") {
+ finishSWTest();
+ return;
+ }
+ log(event.data);
+});
+
+navigator.serviceWorker.register("resources/WorkerNavigator_serviceWorker-worker.js", { }).then(function(registration) {
+ registration.installing.postMessage("Object.getOwnPropertyDescriptor(self.navigator.__proto__, 'serviceWorker')");
+ registration.installing.postMessage("navigator.serviceWorker.__proto__ === self.ServiceWorkerContainer.prototype");
+ registration.installing.postMessage("navigator.serviceWorker.controller === null");
+ registration.installing.postMessage("Object.getOwnPropertyDescriptor(self, 'ServiceWorkerContainer')");
+ registration.installing.postMessage("Object.getOwnPropertyDescriptor(self, 'ServiceWorker')");
+ registration.installing.postMessage("Object.getOwnPropertyDescriptor(self, 'ServiceWorkerRegistration')");
+ registration.installing.postMessage("Object.getOwnPropertyDescriptor(self.navigator.serviceWorker.__proto__, 'controller')");
+ registration.installing.postMessage("Object.getOwnPropertyDescriptor(self.navigator.serviceWorker.__proto__, 'register')");
+ registration.installing.postMessage("Object.getOwnPropertyDescriptor(self.navigator.serviceWorker.__proto__, 'getRegistration')");
+ registration.installing.postMessage("Object.getOwnPropertyDescriptor(self.navigator.serviceWorker.__proto__, 'getRegistrations')");
+ registration.installing.postMessage("DONE");
+});
+</script>
+</body>
+</html>
Added: trunk/LayoutTests/http/tests/workers/service/resources/WorkerNavigator_serviceWorker-worker.js (0 => 225221)
--- trunk/LayoutTests/http/tests/workers/service/resources/WorkerNavigator_serviceWorker-worker.js (rev 0)
+++ trunk/LayoutTests/http/tests/workers/service/resources/WorkerNavigator_serviceWorker-worker.js 2017-11-28 18:22:20 UTC (rev 225221)
@@ -0,0 +1,8 @@
+self.addEventListener("message", (event) => {
+ if (event.data ="" "DONE") {
+ event.source.postMessage(event.data);
+ return;
+ }
+ let result = eval(event.data);
+ event.source.postMessage(event.data + " returned " + JSON.stringify(result));
+});
Modified: trunk/Source/WebCore/ChangeLog (225220 => 225221)
--- trunk/Source/WebCore/ChangeLog 2017-11-28 17:39:17 UTC (rev 225220)
+++ trunk/Source/WebCore/ChangeLog 2017-11-28 18:22:20 UTC (rev 225221)
@@ -1,3 +1,36 @@
+2017-11-28 Chris Dumez <[email protected]>
+
+ Start exposing navigator.serviceWorker inside service workers
+ https://bugs.webkit.org/show_bug.cgi?id=180087
+
+ Reviewed by Brady Eidson.
+
+ Start exposing navigator.serviceWorker inside service workers as per:
+ - https://w3c.github.io/ServiceWorker/#navigator-serviceworker
+
+ Although the property is now exposed, the API on ServiceWorkerContainer is not
+ supported yet inside service workers and the promise will be rejected. This will
+ be implemented in a follow-up.
+
+ Test: http/tests/workers/service/WorkerNavigator_serviceWorker.html
+
+ * Sources.txt:
+ * WebCore.xcodeproj/project.pbxproj:
+ * bindings/js/JSWorkerNavigatorCustom.cpp: Added.
+ (WebCore::JSWorkerNavigator::visitAdditionalChildren):
+ * page/WorkerNavigator.idl:
+ * workers/service/ServiceWorker.idl:
+ * workers/service/ServiceWorkerContainer.cpp:
+ (WebCore::ServiceWorkerContainer::controller const):
+ (WebCore::ServiceWorkerContainer::addRegistration):
+ (WebCore::ServiceWorkerContainer::getRegistration):
+ (WebCore::ServiceWorkerContainer::getRegistrations):
+ * workers/service/ServiceWorkerContainer.idl:
+ * workers/service/ServiceWorkerRegistration.cpp:
+ (WebCore::ServiceWorkerRegistration::update):
+ (WebCore::ServiceWorkerRegistration::unregister):
+ * workers/service/ServiceWorkerRegistration.idl:
+
2017-11-28 Simon Fraser <[email protected]>
Modernize GraphicsLayer dumping
Modified: trunk/Source/WebCore/Sources.txt (225220 => 225221)
--- trunk/Source/WebCore/Sources.txt 2017-11-28 17:39:17 UTC (rev 225220)
+++ trunk/Source/WebCore/Sources.txt 2017-11-28 18:22:20 UTC (rev 225221)
@@ -418,6 +418,7 @@
bindings/js/JSWebGPURenderingContextCustom.cpp
bindings/js/JSWorkerGlobalScopeBase.cpp
bindings/js/JSWorkerGlobalScopeCustom.cpp
+bindings/js/JSWorkerNavigatorCustom.cpp
bindings/js/JSXMLDocumentCustom.cpp
bindings/js/JSXMLHttpRequestCustom.cpp
bindings/js/JSXPathNSResolverCustom.cpp
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (225220 => 225221)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2017-11-28 17:39:17 UTC (rev 225220)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2017-11-28 18:22:20 UTC (rev 225221)
@@ -7288,6 +7288,7 @@
46EFAF0D1E5FB9C200E7F34B /* LowPowerModeNotifierIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LowPowerModeNotifierIOS.mm; sourceTree = "<group>"; };
46EFAF0F1E5FB9E100E7F34B /* LowPowerModeNotifier.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LowPowerModeNotifier.cpp; sourceTree = "<group>"; };
46EFAF101E5FB9E100E7F34B /* LowPowerModeNotifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LowPowerModeNotifier.h; sourceTree = "<group>"; };
+ 46F91BC91FCDD0FE001599C3 /* JSWorkerNavigatorCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSWorkerNavigatorCustom.cpp; sourceTree = "<group>"; };
490707E41219C04300D90E51 /* ANGLEWebKitBridge.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ANGLEWebKitBridge.cpp; sourceTree = "<group>"; };
490707E51219C04300D90E51 /* ANGLEWebKitBridge.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ANGLEWebKitBridge.h; sourceTree = "<group>"; };
49291E4A134172C800E753DE /* ImageRenderingMode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageRenderingMode.h; sourceTree = "<group>"; };
@@ -18961,6 +18962,7 @@
31A088C41E737B2C003B6609 /* JSWebGPURenderingContextCustom.cpp */,
31A088C51E737B2C003B6609 /* JSWebGPURenderPassAttachmentDescriptorCustom.cpp */,
E18258AB0EF3CD7000933242 /* JSWorkerGlobalScopeCustom.cpp */,
+ 46F91BC91FCDD0FE001599C3 /* JSWorkerNavigatorCustom.cpp */,
83A4A9F81CE7FD7E00709B00 /* JSXMLDocumentCustom.cpp */,
836C14421CDEAFCA0073493F /* JSXPathNSResolverCustom.cpp */,
A1C7FAA1133A5D3500D6732D /* JSXPathResultCustom.cpp */,
Copied: trunk/Source/WebCore/bindings/js/JSWorkerNavigatorCustom.cpp (from rev 225220, trunk/Source/WebCore/workers/service/ServiceWorkerRegistration.idl) (0 => 225221)
--- trunk/Source/WebCore/bindings/js/JSWorkerNavigatorCustom.cpp (rev 0)
+++ trunk/Source/WebCore/bindings/js/JSWorkerNavigatorCustom.cpp 2017-11-28 18:22:20 UTC (rev 225221)
@@ -0,0 +1,40 @@
+/*
+ * 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"
+#include "JSWorkerNavigator.h"
+
+namespace WebCore {
+
+void JSWorkerNavigator::visitAdditionalChildren(SlotVisitor& visitor)
+{
+#if ENABLE(SERVICE_WORKER)
+ visitor.addOpaqueRoot(&wrapped().serviceWorker());
+#else
+ UNUSED_PARAM(visitor);
+#endif
+}
+
+}
Modified: trunk/Source/WebCore/page/WorkerNavigator.idl (225220 => 225221)
--- trunk/Source/WebCore/page/WorkerNavigator.idl 2017-11-28 17:39:17 UTC (rev 225220)
+++ trunk/Source/WebCore/page/WorkerNavigator.idl 2017-11-28 18:22:20 UTC (rev 225221)
@@ -29,6 +29,7 @@
[
Exposed=Worker,
GenerateIsReachable=Impl,
+ JSCustomMarkFunction,
] interface WorkerNavigator {
};
@@ -35,3 +36,4 @@
WorkerNavigator implements NavigatorID;
WorkerNavigator implements NavigatorLanguage;
WorkerNavigator implements NavigatorOnLine;
+WorkerNavigator implements NavigatorServiceWorker;
Modified: trunk/Source/WebCore/workers/service/ServiceWorker.idl (225220 => 225221)
--- trunk/Source/WebCore/workers/service/ServiceWorker.idl 2017-11-28 17:39:17 UTC (rev 225220)
+++ trunk/Source/WebCore/workers/service/ServiceWorker.idl 2017-11-28 18:22:20 UTC (rev 225221)
@@ -29,7 +29,7 @@
[
ActiveDOMObject,
SecureContext,
- Exposed=(Window),
+ Exposed=(Window,ServiceWorker),
Conditional=SERVICE_WORKER,
EnabledAtRuntime=ServiceWorker
] interface ServiceWorker : EventTarget {
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerContainer.cpp (225220 => 225221)
--- trunk/Source/WebCore/workers/service/ServiceWorkerContainer.cpp 2017-11-28 17:39:17 UTC (rev 225220)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerContainer.cpp 2017-11-28 18:22:20 UTC (rev 225221)
@@ -78,6 +78,7 @@
ServiceWorker* ServiceWorkerContainer::controller() const
{
auto* context = scriptExecutionContext();
+ ASSERT_WITH_MESSAGE(!context || is<Document>(*context) || !context->activeServiceWorker(), "Only documents can have a controller at the moment.");
return context ? context->activeServiceWorker() : nullptr;
}
@@ -90,6 +91,12 @@
return;
}
+ // FIXME: Add support in workers.
+ if (!is<Document>(*context)) {
+ promise->reject(Exception { NotSupportedError, ASCIILiteral("serviceWorker.register() is not yet supported in workers") });
+ return;
+ }
+
if (relativeScriptURL.isEmpty()) {
promise->reject(Exception { TypeError, ASCIILiteral("serviceWorker.register() cannot be called with an empty script URL") });
return;
@@ -212,6 +219,12 @@
return;
}
+ // FIXME: Add support in workers.
+ if (!is<Document>(*context)) {
+ promise->reject(Exception { NotSupportedError, ASCIILiteral("serviceWorker.getRegistration() is not yet supported in workers") });
+ return;
+ }
+
URL parsedURL = context->completeURL(clientURL);
if (!protocolHostAndPortAreEqual(parsedURL, context->url())) {
promise->reject(Exception { SecurityError, ASCIILiteral("Origin of clientURL is not client's origin") });
@@ -259,6 +272,12 @@
return;
}
+ // FIXME: Add support in workers.
+ if (!is<Document>(*context)) {
+ promise.reject(Exception { NotSupportedError, ASCIILiteral("serviceWorker.getRegistrations() is not yet supported in workers") });
+ return;
+ }
+
if (!m_swConnection)
m_swConnection = &ServiceWorkerProvider::singleton().serviceWorkerConnectionForSession(context->sessionID());
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerContainer.idl (225220 => 225221)
--- trunk/Source/WebCore/workers/service/ServiceWorkerContainer.idl 2017-11-28 17:39:17 UTC (rev 225220)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerContainer.idl 2017-11-28 18:22:20 UTC (rev 225221)
@@ -28,7 +28,7 @@
[
SecureContext,
- Exposed=(Window),
+ Exposed=(Window,ServiceWorker),
Conditional=SERVICE_WORKER,
EnabledAtRuntime=ServiceWorker,
GenerateIsReachable=Impl,
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerRegistration.cpp (225220 => 225221)
--- trunk/Source/WebCore/workers/service/ServiceWorkerRegistration.cpp 2017-11-28 17:39:17 UTC (rev 225220)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerRegistration.cpp 2017-11-28 18:22:20 UTC (rev 225221)
@@ -121,6 +121,12 @@
return;
}
+ // FIXME: Add support in workers.
+ if (!is<Document>(*context)) {
+ promise->reject(Exception { NotSupportedError, ASCIILiteral("serviceWorkerRegistration.update() is not yet supported in workers") });
+ return;
+ }
+
auto* container = context->serviceWorkerContainer();
if (!container) {
promise->reject(Exception(InvalidStateError));
@@ -146,6 +152,12 @@
return;
}
+ // FIXME: Add support in workers.
+ if (!is<Document>(*context)) {
+ promise->reject(Exception { NotSupportedError, ASCIILiteral("serviceWorkerRegistration.unregister() is not yet supported in workers") });
+ return;
+ }
+
auto* container = context->serviceWorkerContainer();
if (!container) {
promise->reject(Exception(InvalidStateError));
Modified: trunk/Source/WebCore/workers/service/ServiceWorkerRegistration.idl (225220 => 225221)
--- trunk/Source/WebCore/workers/service/ServiceWorkerRegistration.idl 2017-11-28 17:39:17 UTC (rev 225220)
+++ trunk/Source/WebCore/workers/service/ServiceWorkerRegistration.idl 2017-11-28 18:22:20 UTC (rev 225221)
@@ -29,7 +29,7 @@
[
ActiveDOMObject,
SecureContext,
- Exposed=(Window),
+ Exposed=(Window,ServiceWorker),
Conditional=SERVICE_WORKER,
EnabledAtRuntime=ServiceWorker
] interface ServiceWorkerRegistration : EventTarget {