mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1154721 - Add an "Unregister" button to about:serviceworkers, r=ehsan
This commit is contained in:
parent
2d11560001
commit
9af7bcd327
@ -11,13 +11,13 @@ interface nsIInterceptedChannel;
|
||||
interface nsIPrincipal;
|
||||
interface nsIURI;
|
||||
|
||||
[builtinclass, uuid(d4367ffe-e435-4195-95f8-0a51b1bbfdfb)]
|
||||
[scriptable, uuid(52ee2c9d-ee87-4caf-9588-23ae77ff8798)]
|
||||
interface nsIServiceWorkerUnregisterCallback : nsISupports
|
||||
{
|
||||
// aState is true if the unregistration succeded.
|
||||
// It's false if this ServiceWorkerRegistration doesn't exist.
|
||||
[noscript] void UnregisterSucceeded(in bool aState);
|
||||
[noscript] void UnregisterFailed();
|
||||
void unregisterSucceeded(in bool aState);
|
||||
void unregisterFailed();
|
||||
};
|
||||
|
||||
[scriptable, builtinclass, uuid(8ce0d197-5740-4ddf-aa4a-e5a63e611d03)]
|
||||
|
@ -1778,7 +1778,7 @@ private:
|
||||
nsRefPtr<ServiceWorkerRegistrationInfo> registration;
|
||||
if (!swm->mServiceWorkerRegistrationInfos.Get(mScope, getter_AddRefs(registration))) {
|
||||
// "If registration is null, then, resolve promise with false."
|
||||
return mCallback->UnregisterSucceeded(false);
|
||||
return mCallback ? mCallback->UnregisterSucceeded(false) : NS_OK;
|
||||
}
|
||||
|
||||
MOZ_ASSERT(registration);
|
||||
@ -1786,7 +1786,7 @@ private:
|
||||
// "Set registration's uninstalling flag."
|
||||
registration->mPendingUninstall = true;
|
||||
// "Resolve promise with true"
|
||||
nsresult rv = mCallback->UnregisterSucceeded(true);
|
||||
nsresult rv = mCallback ? mCallback->UnregisterSucceeded(true) : NS_OK;
|
||||
if (NS_WARN_IF(NS_FAILED(rv))) {
|
||||
return rv;
|
||||
}
|
||||
@ -1824,8 +1824,10 @@ ServiceWorkerManager::Unregister(nsIPrincipal* aPrincipal,
|
||||
const nsAString& aScope)
|
||||
{
|
||||
AssertIsOnMainThread();
|
||||
MOZ_ASSERT(aPrincipal);
|
||||
MOZ_ASSERT(aCallback);
|
||||
|
||||
if (!aPrincipal) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// This is not accessible by content, and callers should always ensure scope is
|
||||
// a correct URI, so this is wrapped in DEBUG
|
||||
|
@ -7,11 +7,13 @@
|
||||
const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
|
||||
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import('resource://gre/modules/XPCOMUtils.jsm');
|
||||
|
||||
const bundle = Services.strings.createBundle(
|
||||
"chrome://global/locale/aboutServiceWorkers.properties");
|
||||
|
||||
let gSWM;
|
||||
let gSWCount = 0;
|
||||
|
||||
function init() {
|
||||
let enabled = Services.prefs.getBoolPref("dom.serviceWorkers.enabled");
|
||||
@ -99,15 +101,48 @@ function display(info) {
|
||||
createItem(bundle.GetStringFromName('activeCacheName'), info.activeCacheName);
|
||||
createItem(bundle.GetStringFromName('waitingCacheName'), info.waitingCacheName);
|
||||
|
||||
var updateButton = document.createElement("button");
|
||||
let updateButton = document.createElement("button");
|
||||
updateButton.appendChild(document.createTextNode(bundle.GetStringFromName('update')));
|
||||
updateButton.onclick = function() {
|
||||
gSWM.update(info.scope);
|
||||
};
|
||||
div.appendChild(updateButton);
|
||||
|
||||
let unregisterButton = document.createElement("button");
|
||||
unregisterButton.appendChild(document.createTextNode(bundle.GetStringFromName('unregister')));
|
||||
div.appendChild(unregisterButton);
|
||||
|
||||
let loadingMessage = document.createElement('span');
|
||||
loadingMessage.appendChild(document.createTextNode(bundle.GetStringFromName('waiting')));
|
||||
loadingMessage.classList.add('inactive');
|
||||
div.appendChild(loadingMessage);
|
||||
|
||||
unregisterButton.onclick = function() {
|
||||
let cb = {
|
||||
unregisterSucceeded: function() {
|
||||
parent.removeChild(div);
|
||||
|
||||
if (!--gSWCount) {
|
||||
let div = document.getElementById("warning_no_serviceworkers");
|
||||
div.classList.add("active");
|
||||
}
|
||||
},
|
||||
|
||||
unregisterFailed: function() {
|
||||
alert(bundle.GetStringFromName('unregisterError'));
|
||||
},
|
||||
|
||||
QueryInterface: XPCOMUtils.generateQI([Ci.nsIServiceWorkerUnregisterCallback])
|
||||
};
|
||||
|
||||
loadingMessage.classList.remove('inactive');
|
||||
gSWM.unregister(info.principal, cb, info.scope);
|
||||
};
|
||||
|
||||
let sep = document.createElement('hr');
|
||||
div.appendChild(sep);
|
||||
|
||||
++gSWCount;
|
||||
}
|
||||
|
||||
window.addEventListener("DOMContentLoaded", function load() {
|
||||
|
@ -23,3 +23,10 @@ true = true
|
||||
false = false
|
||||
|
||||
update = Update
|
||||
|
||||
unregister = Unregister
|
||||
|
||||
waiting = Waiting...
|
||||
|
||||
# LOCALIZATION NODE the term "Service Worker" should not translated.
|
||||
unregisterError = Failed to unregister this Service Worker.
|
||||
|
@ -38,3 +38,7 @@ body {
|
||||
.active {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.inactive {
|
||||
display: none;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user