Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
Showing
9 changed files
with
115 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -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 | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@@ -19,6 +19,7 @@ | ||
|
||
[ | ||
GenerateIsReachable=ImplFrame, | ||
JSCustomMarkFunction, | ||
] interface Navigator { | ||
readonly attribute DOMPluginArray plugins; | ||
readonly attribute DOMMimeTypeArray mimeTypes; | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters