mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 03:15:11 +00:00
Bug 1336043 - close() should be in DedicatedWorkerGlobalScope and SharedWorkerGlobalScope only, r=bkelly
This commit is contained in:
parent
899a146699
commit
c58769de70
@ -300,6 +300,7 @@ DOMInterfaces = {
|
||||
|
||||
'DedicatedWorkerGlobalScope': {
|
||||
'headerFile': 'mozilla/dom/WorkerScope.h',
|
||||
'implicitJSContext': [ 'close' ],
|
||||
},
|
||||
|
||||
'DeviceAcceleration': {
|
||||
@ -830,6 +831,7 @@ DOMInterfaces = {
|
||||
|
||||
'SharedWorkerGlobalScope': {
|
||||
'headerFile': 'mozilla/dom/WorkerScope.h',
|
||||
'implicitJSContext': [ 'close' ],
|
||||
},
|
||||
|
||||
'StyleSheet': {
|
||||
@ -1408,9 +1410,6 @@ DOMInterfaces = {
|
||||
'WorkerGlobalScope': {
|
||||
'headerFile': 'mozilla/dom/WorkerScope.h',
|
||||
'concrete': False,
|
||||
'implicitJSContext': [
|
||||
'close',
|
||||
],
|
||||
# Rename a few things so we don't have both classes and methods
|
||||
# with the same name
|
||||
'binaryNames': {
|
||||
|
@ -18,5 +18,7 @@ interface DedicatedWorkerGlobalScope : WorkerGlobalScope {
|
||||
[Throws]
|
||||
void postMessage(any message, optional sequence<any> transfer);
|
||||
|
||||
void close();
|
||||
|
||||
attribute EventHandler onmessage;
|
||||
};
|
||||
|
@ -16,5 +16,8 @@
|
||||
Exposed=SharedWorker]
|
||||
interface SharedWorkerGlobalScope : WorkerGlobalScope {
|
||||
readonly attribute DOMString name;
|
||||
|
||||
void close();
|
||||
|
||||
attribute EventHandler onconnect;
|
||||
};
|
||||
|
@ -16,11 +16,12 @@
|
||||
interface WorkerGlobalScope : EventTarget {
|
||||
[Constant, Cached]
|
||||
readonly attribute WorkerGlobalScope self;
|
||||
|
||||
readonly attribute WorkerLocation location;
|
||||
readonly attribute WorkerNavigator navigator;
|
||||
|
||||
[Throws]
|
||||
void close();
|
||||
void importScripts(DOMString... urls);
|
||||
|
||||
attribute OnErrorEventHandler onerror;
|
||||
|
||||
attribute EventHandler onoffline;
|
||||
@ -28,13 +29,6 @@ interface WorkerGlobalScope : EventTarget {
|
||||
// also has additional members in a partial interface
|
||||
};
|
||||
|
||||
partial interface WorkerGlobalScope {
|
||||
[Throws]
|
||||
void importScripts(DOMString... urls);
|
||||
|
||||
readonly attribute WorkerNavigator navigator;
|
||||
};
|
||||
|
||||
WorkerGlobalScope implements GlobalCrypto;
|
||||
WorkerGlobalScope implements WindowOrWorkerGlobalScope;
|
||||
|
||||
|
@ -221,18 +221,6 @@ WorkerGlobalScope::GetExistingNavigator() const
|
||||
return navigator.forget();
|
||||
}
|
||||
|
||||
void
|
||||
WorkerGlobalScope::Close(JSContext* aCx, ErrorResult& aRv)
|
||||
{
|
||||
mWorkerPrivate->AssertIsOnWorkerThread();
|
||||
|
||||
if (mWorkerPrivate->IsServiceWorker()) {
|
||||
aRv.Throw(NS_ERROR_DOM_INVALID_ACCESS_ERR);
|
||||
} else {
|
||||
mWorkerPrivate->CloseInternal(aCx);
|
||||
}
|
||||
}
|
||||
|
||||
OnErrorEventHandlerNonNull*
|
||||
WorkerGlobalScope::GetOnerror()
|
||||
{
|
||||
@ -536,6 +524,13 @@ DedicatedWorkerGlobalScope::PostMessage(JSContext* aCx,
|
||||
mWorkerPrivate->PostMessageToParent(aCx, aMessage, aTransferable, aRv);
|
||||
}
|
||||
|
||||
void
|
||||
DedicatedWorkerGlobalScope::Close(JSContext* aCx)
|
||||
{
|
||||
mWorkerPrivate->AssertIsOnWorkerThread();
|
||||
mWorkerPrivate->CloseInternal(aCx);
|
||||
}
|
||||
|
||||
SharedWorkerGlobalScope::SharedWorkerGlobalScope(WorkerPrivate* aWorkerPrivate,
|
||||
const nsCString& aName)
|
||||
: WorkerGlobalScope(aWorkerPrivate), mName(aName)
|
||||
@ -557,6 +552,13 @@ SharedWorkerGlobalScope::WrapGlobalObject(JSContext* aCx,
|
||||
true, aReflector);
|
||||
}
|
||||
|
||||
void
|
||||
SharedWorkerGlobalScope::Close(JSContext* aCx)
|
||||
{
|
||||
mWorkerPrivate->AssertIsOnWorkerThread();
|
||||
mWorkerPrivate->CloseInternal(aCx);
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_INHERITED(ServiceWorkerGlobalScope, WorkerGlobalScope,
|
||||
mClients, mRegistration)
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(ServiceWorkerGlobalScope)
|
||||
|
@ -112,9 +112,6 @@ public:
|
||||
already_AddRefed<WorkerNavigator>
|
||||
GetExistingNavigator() const;
|
||||
|
||||
void
|
||||
Close(JSContext* aCx, ErrorResult& aRv);
|
||||
|
||||
OnErrorEventHandlerNonNull*
|
||||
GetOnerror();
|
||||
void
|
||||
@ -218,6 +215,9 @@ public:
|
||||
const Optional<Sequence<JS::Value>>& aTransferable,
|
||||
ErrorResult& aRv);
|
||||
|
||||
void
|
||||
Close(JSContext* aCx);
|
||||
|
||||
IMPL_EVENT_HANDLER(message)
|
||||
};
|
||||
|
||||
@ -240,6 +240,9 @@ public:
|
||||
aName.AsAString() = NS_ConvertUTF8toUTF16(mName);
|
||||
}
|
||||
|
||||
void
|
||||
Close(JSContext* aCx);
|
||||
|
||||
IMPL_EVENT_HANDLER(connect)
|
||||
};
|
||||
|
||||
|
@ -115,7 +115,6 @@ support-files =
|
||||
test_serviceworker_interfaces.js
|
||||
serviceworker_wrapper.js
|
||||
message_receiver.html
|
||||
close_test.js
|
||||
serviceworker_not_sharedworker.js
|
||||
match_all_client/match_all_client_id.html
|
||||
match_all_client_id_worker.js
|
||||
@ -221,7 +220,6 @@ support-files =
|
||||
[test_claim.html]
|
||||
[test_claim_fetch.html]
|
||||
[test_claim_oninstall.html]
|
||||
[test_close.html]
|
||||
[test_controller.html]
|
||||
[test_cross_origin_url_after_redirect.html]
|
||||
[test_csp_upgrade-insecure_intercept.html]
|
||||
|
@ -1,64 +0,0 @@
|
||||
<!--
|
||||
Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/
|
||||
-->
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Bug 1131353 - test WorkerGlobalScope.close() on service workers</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
||||
</head>
|
||||
<body>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
<iframe></iframe>
|
||||
</div>
|
||||
<pre id="test"></pre>
|
||||
<script class="testbody" type="text/javascript">
|
||||
|
||||
var iframe;
|
||||
function runTest() {
|
||||
navigator.serviceWorker.ready.then(setupSW);
|
||||
navigator.serviceWorker.register("close_test.js", {scope: "."});
|
||||
|
||||
function setupSW(registration) {
|
||||
var worker = registration.waiting ||
|
||||
registration.active;
|
||||
var iframe = document.createElement("iframe");
|
||||
iframe.src = "message_receiver.html";
|
||||
iframe.onload = function() {
|
||||
worker.postMessage({ message: "start" });
|
||||
};
|
||||
document.body.appendChild(iframe);
|
||||
}
|
||||
|
||||
window.onmessage = function(e) {
|
||||
if (e.data.status == "ok") {
|
||||
ok(e.data.result, e.data.message);
|
||||
} else if (e.data.status == "done") {
|
||||
navigator.serviceWorker.getRegistration().then(function(registration) {
|
||||
registration.unregister().then(function(result) {
|
||||
ok(result, "Unregistering the service worker should succeed");
|
||||
SimpleTest.finish();
|
||||
}, function(e) {
|
||||
dump("Unregistering the SW failed with " + e + "\n");
|
||||
SimpleTest.finish();
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
onload = function() {
|
||||
SpecialPowers.pushPrefEnv({"set": [
|
||||
["dom.serviceWorkers.exemptFromPerDomainMax", true],
|
||||
["dom.serviceWorkers.enabled", true],
|
||||
["dom.serviceWorkers.testing.enabled", true],
|
||||
]}, runTest);
|
||||
};
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
@ -28,7 +28,6 @@ interface WorkerGlobalScope : EventTarget {
|
||||
readonly attribute WorkerGlobalScope self;
|
||||
readonly attribute WorkerLocation location;
|
||||
|
||||
void close();
|
||||
attribute OnErrorEventHandler onerror;
|
||||
attribute EventHandler onlanguagechange;
|
||||
attribute EventHandler onoffline;
|
||||
@ -38,6 +37,7 @@ interface WorkerGlobalScope : EventTarget {
|
||||
[Global=(Worker,DedicatedWorker),Exposed=DedicatedWorker]
|
||||
/*sealed*/ interface DedicatedWorkerGlobalScope : WorkerGlobalScope {
|
||||
void postMessage(any message, optional sequence<Transferable> transfer);
|
||||
void close();
|
||||
attribute EventHandler onmessage;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user