Skip to content
Permalink
Browse files
navigator.serviceWorker should always return the same object
https://bugs.webkit.org/show_bug.cgi?id=179067

Reviewed by Youenn Fablet.

Source/WebCore:

navigator.serviceWorker should always return the same object:
- https://www.w3.org/TR/service-workers-1/#navigator-service-worker

Add visitor to make sure we don't gc() the ServiceWorkerContainer wrapper too early.

Test: http/tests/workers/service/navigator-serviceWorker-same-object.html

* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSNavigatorCustom.cpp: Copied from Source/WebCore/workers/service/ServiceWorkerContainer.idl.
(WebCore::JSNavigator::visitAdditionalChildren):
* page/Navigator.idl:
* workers/service/ServiceWorkerContainer.idl:

LayoutTests:

Add layout test coverage.

* http/tests/workers/service/navigator-serviceWorker-same-object-expected.txt: Added.
* http/tests/workers/service/navigator-serviceWorker-same-object.html: Added.

Canonical link: https://commits.webkit.org/195200@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224244 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
cdumez committed Oct 31, 2017
1 parent b485091 commit 96416bf629b2756036e8004ca5f97411dad3abc6
Showing 9 changed files with 115 additions and 1 deletion.
@@ -1,3 +1,15 @@
2017-10-31 Chris Dumez <cdumez@apple.com>

navigator.serviceWorker should always return the same object
https://bugs.webkit.org/show_bug.cgi?id=179067

Reviewed by Youenn Fablet.

Add layout test coverage.

* http/tests/workers/service/navigator-serviceWorker-same-object-expected.txt: Added.
* http/tests/workers/service/navigator-serviceWorker-same-object.html: Added.

2017-10-31 Antoine Quint <graouts@apple.com>

[Web Animations] Support AnimationEffect parameter in Animation constructor and read-write timeline property
@@ -0,0 +1,13 @@
Tests that navigator.serviceWorker always returns the same object.

On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".


PASS navigator.serviceWorker.foo is undefined.
PASS navigator.serviceWorker.foo is 1
PASS navigator.serviceWorker.foo is 1
PASS navigator.serviceWorker.foo is 1
PASS successfullyParsed is true

TEST COMPLETE

@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html>
<body>
<script src="/js-test-resources/js-test.js"></script>
<script>
description("Tests that navigator.serviceWorker always returns the same object.");
jsTestIsAsync = true;

shouldBeUndefined("navigator.serviceWorker.foo");
navigator.serviceWorker.foo = 1;
shouldBe("navigator.serviceWorker.foo", "1");
gc();
shouldBe("navigator.serviceWorker.foo", "1");
setTimeout(function() {
gc();
shouldBe("navigator.serviceWorker.foo", "1");

finishJSTest();
}, 0);

</script>
</body>
</html>
@@ -1,3 +1,24 @@
2017-10-31 Chris Dumez <cdumez@apple.com>

navigator.serviceWorker should always return the same object
https://bugs.webkit.org/show_bug.cgi?id=179067

Reviewed by Youenn Fablet.

navigator.serviceWorker should always return the same object:
- https://www.w3.org/TR/service-workers-1/#navigator-service-worker

Add visitor to make sure we don't gc() the ServiceWorkerContainer wrapper too early.

Test: http/tests/workers/service/navigator-serviceWorker-same-object.html

* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* bindings/js/JSNavigatorCustom.cpp: Copied from Source/WebCore/workers/service/ServiceWorkerContainer.idl.
(WebCore::JSNavigator::visitAdditionalChildren):
* page/Navigator.idl:
* workers/service/ServiceWorkerContainer.idl:

2017-10-31 Antoine Quint <graouts@apple.com>

[Web Animations] Support AnimationEffect parameter in Animation constructor and read-write timeline property
@@ -392,6 +392,7 @@ bindings/js/JSMessageChannelCustom.cpp
bindings/js/JSMessageEventCustom.cpp
bindings/js/JSMessagePortCustom.cpp
bindings/js/JSMutationObserverCustom.cpp
bindings/js/JSNavigatorCustom.cpp
bindings/js/JSNodeCustom.cpp
bindings/js/JSNodeIteratorCustom.cpp
bindings/js/JSNodeListCustom.cpp
@@ -9487,6 +9487,7 @@
83A4A9F81CE7FD7E00709B00 /* JSXMLDocumentCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSXMLDocumentCustom.cpp; sourceTree = "<group>"; };
83B250091FA1181C00BC02D9 /* JSServiceWorkerClientType.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSServiceWorkerClientType.h; sourceTree = "<group>"; };
83B2500B1FA1181D00BC02D9 /* JSServiceWorkerClientType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSServiceWorkerClientType.cpp; sourceTree = "<group>"; };
83B5DA451FA9079300B59DF4 /* JSNavigatorCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSNavigatorCustom.cpp; sourceTree = "<group>"; };
83B74EF21F3E0BD700996BC7 /* KeepaliveRequestTracker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KeepaliveRequestTracker.cpp; sourceTree = "<group>"; };
83B74EF31F3E0BD700996BC7 /* KeepaliveRequestTracker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KeepaliveRequestTracker.h; sourceTree = "<group>"; };
83B9687919F8AB83004EF7AF /* StyleBuilderConverter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleBuilderConverter.h; sourceTree = "<group>"; };
@@ -18923,6 +18924,7 @@
E1A5F99A0E7EAA2500AF85EA /* JSMessageChannelCustom.cpp */,
E1ADED460E76B8DD004A1A5E /* JSMessagePortCustom.cpp */,
C6F0917E143A2BB900685849 /* JSMutationObserverCustom.cpp */,
83B5DA451FA9079300B59DF4 /* JSNavigatorCustom.cpp */,
BCD9C2600C17AA67005C90A2 /* JSNodeCustom.cpp */,
BC9439C2116CF4940048C750 /* JSNodeCustom.h */,
1A750DD30A90E729000FF215 /* JSNodeIteratorCustom.cpp */,
@@ -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 "JSNavigator.h"

namespace WebCore {

void JSNavigator::visitAdditionalChildren(SlotVisitor& visitor)
{
#if ENABLE(SERVICE_WORKER)
visitor.addOpaqueRoot(wrapped().serviceWorker());
#else
UNUSED_PARAM(visitor);
#endif
}

}
@@ -19,6 +19,7 @@

[
GenerateIsReachable=ImplFrame,
JSCustomMarkFunction,
] interface Navigator {
readonly attribute DOMPluginArray plugins;
readonly attribute DOMMimeTypeArray mimeTypes;
@@ -30,7 +30,8 @@
SecureContext,
Exposed=(Window),
Conditional=SERVICE_WORKER,
EnabledAtRuntime=ServiceWorker
EnabledAtRuntime=ServiceWorker,
GenerateIsReachable=Impl,
] interface ServiceWorkerContainer : EventTarget {
readonly attribute ServiceWorker? controller;
readonly attribute Promise<ServiceWorkerRegistration> ready;

0 comments on commit 96416bf

Please sign in to comment.