Skip to content
Permalink
Browse files
self.ExtendableEvent / Client / Clients / WindowClient do not exist i…
…n a Service Worker

https://bugs.webkit.org/show_bug.cgi?id=178976

Reviewed by Sam Weinig.

Source/WebCore:

Test: http/tests/workers/service/ServiceWorkerGlobalScope-properties.html

* workers/service/ExtendableEvent.idl:
* workers/service/FetchEvent.idl:
Drop [Exposed=Worker] as there is already [Exposed=ServiceWorker] and
ServiceWorkerGlobalScope inherits from WorkerGlobalScope. This is redundant
and we would hit assertions and adding the global constructors at runtime
when the feature is enabled, because the property already exists.

Source/WebKit:

Actually enable the Service Worker RuntimeEnabledFeature in the Service Worker
WebProcess.

* WebProcess/Storage/WebSWContextManagerConnection.cpp:
(WebKit::WebSWContextManagerConnection::updatePreferences):

LayoutTests:

Add layout test coverage.

* http/tests/workers/service/ServiceWorkerGlobalScope-properties-expected.txt: Added.
* http/tests/workers/service/ServiceWorkerGlobalScope-properties.html: Added.
* http/tests/workers/service/resources/ServiceWorkerGlobalScope-properties-worker.js: Added.


Canonical link: https://commits.webkit.org/195122@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224153 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
cdumez committed Oct 28, 2017
1 parent 88b2692 commit c03b5dbdebd62294dfb2f641c171c19045d951c8
Showing 9 changed files with 99 additions and 2 deletions.
@@ -1,3 +1,16 @@
2017-10-28 Chris Dumez <cdumez@apple.com>

self.ExtendableEvent / Client / Clients / WindowClient do not exist in a Service Worker
https://bugs.webkit.org/show_bug.cgi?id=178976

Reviewed by Sam Weinig.

Add layout test coverage.

* http/tests/workers/service/ServiceWorkerGlobalScope-properties-expected.txt: Added.
* http/tests/workers/service/ServiceWorkerGlobalScope-properties.html: Added.
* http/tests/workers/service/resources/ServiceWorkerGlobalScope-properties-worker.js: Added.

2017-10-27 Devin Rousso <webkit@devinrousso.com>

Web Inspector: Canvas Tab: no way to see backtrace of where a canvas context was created
@@ -0,0 +1,21 @@
* ServiceWorkerGlobalScope properties
Object.getOwnPropertyDescriptor(self, 'Blob') returned {"writable":true,"enumerable":false,"configurable":true}
Object.getOwnPropertyDescriptor(self, 'Cache') returned {"writable":true,"enumerable":false,"configurable":true}
Object.getOwnPropertyDescriptor(self, 'CacheStorage') returned {"writable":true,"enumerable":false,"configurable":true}
Object.getOwnPropertyDescriptor(self, 'Client') returned {"writable":true,"enumerable":false,"configurable":true}
Object.getOwnPropertyDescriptor(self, 'Clients') returned {"writable":true,"enumerable":false,"configurable":true}
Object.getOwnPropertyDescriptor(self, 'ExtendableEvent') returned {"writable":true,"enumerable":false,"configurable":true}
Object.getOwnPropertyDescriptor(self, 'ExtendableMessageEvent') returned {"writable":true,"enumerable":false,"configurable":true}
Object.getOwnPropertyDescriptor(self, 'FetchEvent') returned {"writable":true,"enumerable":false,"configurable":true}
Object.getOwnPropertyDescriptor(self, 'Headers') returned {"writable":true,"enumerable":false,"configurable":true}
Object.getOwnPropertyDescriptor(self, 'MessageChannel') returned {"writable":true,"enumerable":false,"configurable":true}
Object.getOwnPropertyDescriptor(self, 'MessageEvent') returned {"writable":true,"enumerable":false,"configurable":true}
Object.getOwnPropertyDescriptor(self, 'MessagePort') returned {"writable":true,"enumerable":false,"configurable":true}
Object.getOwnPropertyDescriptor(self, 'Request') returned {"writable":true,"enumerable":false,"configurable":true}
Object.getOwnPropertyDescriptor(self, 'Response') returned {"writable":true,"enumerable":false,"configurable":true}
Object.getOwnPropertyDescriptor(self, 'ServiceWorkerGlobalScope') returned {"writable":true,"enumerable":false,"configurable":true}
Object.getOwnPropertyDescriptor(self, 'WebSocket') returned {"writable":true,"enumerable":false,"configurable":true}
Object.getOwnPropertyDescriptor(self, 'WindowClient') returned {"writable":true,"enumerable":false,"configurable":true}
Object.getOwnPropertyDescriptor(self, 'WorkerGlobalScope') returned {"writable":true,"enumerable":false,"configurable":true}
Object.getOwnPropertyDescriptor(self, 'XMLHttpRequest') returned {"writable":true,"enumerable":false,"configurable":true}

@@ -0,0 +1,29 @@
<!DOCTYPE html>
<html>
<body>
<script src="resources/sw-test-pre.js"></script>
<script>
log("* ServiceWorkerGlobalScope properties");

const expectedProperties = [
"Blob", "Cache", "CacheStorage", "Client", "Clients", "ExtendableEvent", "ExtendableMessageEvent",
"FetchEvent", "Headers", "MessageChannel", "MessageEvent", "MessagePort", "Request", "Response",
"ServiceWorkerGlobalScope", "WebSocket", "WindowClient", "WorkerGlobalScope", "XMLHttpRequest"];

let receivedMessages = 0;

navigator.serviceWorker.addEventListener("message", function(event) {
log(event.data);

receivedMessages++;
if (receivedMessages == expectedProperties.length)
finishSWTest();
});

navigator.serviceWorker.register("resources/ServiceWorkerGlobalScope-properties-worker.js", { }).then(function() {
for (let property of expectedProperties)
navigator.serviceWorker.controller.postMessage("Object.getOwnPropertyDescriptor(self, '" + property + "')");
});
</script>
</body>
</html>
@@ -0,0 +1,4 @@
self.addEventListener("message", (event) => {
let result = eval(event.data);
event.source.postMessage(event.data + " returned " + JSON.stringify(result));
});
@@ -1,3 +1,19 @@
2017-10-28 Chris Dumez <cdumez@apple.com>

self.ExtendableEvent / Client / Clients / WindowClient do not exist in a Service Worker
https://bugs.webkit.org/show_bug.cgi?id=178976

Reviewed by Sam Weinig.

Test: http/tests/workers/service/ServiceWorkerGlobalScope-properties.html

* workers/service/ExtendableEvent.idl:
* workers/service/FetchEvent.idl:
Drop [Exposed=Worker] as there is already [Exposed=ServiceWorker] and
ServiceWorkerGlobalScope inherits from WorkerGlobalScope. This is redundant
and we would hit assertions and adding the global constructors at runtime
when the feature is enabled, because the property already exists.

2017-10-28 Zalan Bujtas <zalan@apple.com>

[FrameView::layout cleanup] Move core layout logic to a separate class.
@@ -28,7 +28,7 @@
Constructor(DOMString type, optional ExtendableEventInit eventInitDict),
Conditional=SERVICE_WORKER,
EnabledAtRuntime=ServiceWorker,
Exposed=(ServiceWorker,Worker,Window),
Exposed=(ServiceWorker,Window),
ExportMacro=WEBCORE_EXPORT,
JSGenerateToNativeObject,
] interface ExtendableEvent : Event {
@@ -30,7 +30,7 @@
JSCustomMarkFunction,
EnabledAtRuntime=ServiceWorker,
ExportMacro=WEBCORE_EXPORT,
Exposed=(ServiceWorker,Worker,Window),
Exposed=(ServiceWorker,Window),
JSGenerateToNativeObject
] interface FetchEvent : ExtendableEvent {
[SameObject] readonly attribute FetchRequest request;
@@ -1,3 +1,16 @@
2017-10-28 Chris Dumez <cdumez@apple.com>

self.ExtendableEvent / Client / Clients / WindowClient do not exist in a Service Worker
https://bugs.webkit.org/show_bug.cgi?id=178976

Reviewed by Sam Weinig.

Actually enable the Service Worker RuntimeEnabledFeature in the Service Worker
WebProcess.

* WebProcess/Storage/WebSWContextManagerConnection.cpp:
(WebKit::WebSWContextManagerConnection::updatePreferences):

2017-10-28 Joseph Pecoraro <pecoraro@apple.com>

Make postprocess-framework-headers.sh a little easier to read
@@ -90,6 +90,7 @@ WebSWContextManagerConnection::WebSWContextManagerConnection(Ref<IPC::Connection

void WebSWContextManagerConnection::updatePreferences(const WebPreferencesStore& store)
{
RuntimeEnabledFeatures::sharedFeatures().setServiceWorkerEnabled(true);
RuntimeEnabledFeatures::sharedFeatures().setCacheAPIEnabled(store.getBoolValueForKey(WebPreferencesKey::cacheAPIEnabledKey()));
RuntimeEnabledFeatures::sharedFeatures().setFetchAPIEnabled(store.getBoolValueForKey(WebPreferencesKey::fetchAPIEnabledKey()));
}

0 comments on commit c03b5db

Please sign in to comment.