mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-07 18:04:46 +00:00
Bug 1328293 - Show if a service worker is listening for fetch events in about:debugging. r=jdescottes
This commit is contained in:
parent
130fcb1f75
commit
1609baa123
@ -76,6 +76,7 @@ module.exports = createClass({
|
||||
name: form.url,
|
||||
url: form.url,
|
||||
scope: form.scope,
|
||||
fetch: form.fetch,
|
||||
registrationActor: form.actor,
|
||||
active: form.active
|
||||
});
|
||||
@ -99,6 +100,8 @@ module.exports = createClass({
|
||||
}
|
||||
registration.workerActor = form.actor;
|
||||
} else {
|
||||
worker.fetch = form.fetch;
|
||||
|
||||
// If a service worker registration could not be found, this means we are in
|
||||
// e10s, and registrations are not forwarded to other processes until they
|
||||
// reach the activated state. Augment the worker as a registration worker to
|
||||
|
@ -25,6 +25,7 @@ module.exports = createClass({
|
||||
debugDisabled: PropTypes.bool,
|
||||
target: PropTypes.shape({
|
||||
active: PropTypes.bool,
|
||||
fetch: PropTypes.bool.isRequired,
|
||||
icon: PropTypes.string,
|
||||
name: PropTypes.string.isRequired,
|
||||
url: PropTypes.string,
|
||||
@ -195,6 +196,9 @@ module.exports = createClass({
|
||||
let { pushSubscription } = this.state;
|
||||
let status = this.getServiceWorkerStatus();
|
||||
|
||||
let fetch = target.fetch ? Strings.GetStringFromName("listeningForFetchEvents") :
|
||||
Strings.GetStringFromName("notListeningForFetchEvents");
|
||||
|
||||
return dom.div({ className: "target-container" },
|
||||
dom.img({
|
||||
className: "target-icon",
|
||||
@ -215,6 +219,12 @@ module.exports = createClass({
|
||||
}, pushSubscription.endpoint)) :
|
||||
null
|
||||
),
|
||||
dom.li({ className: "target-detail" },
|
||||
dom.strong(null, Strings.GetStringFromName("fetch")),
|
||||
dom.span({
|
||||
className: "service-worker-fetch-flag",
|
||||
title: fetch
|
||||
}, fetch)),
|
||||
dom.li({ className: "target-detail" },
|
||||
dom.strong(null, Strings.GetStringFromName("scope")),
|
||||
dom.span({
|
||||
|
@ -21,6 +21,18 @@ unregister = unregister
|
||||
|
||||
pushService = Push Service
|
||||
|
||||
# LOCALIZATION NOTE (fetch):
|
||||
# Fetch is an event type and should not be translated.
|
||||
fetch = Fetch
|
||||
|
||||
# LOCALIZATION NOTE (listeningForFetchEvents):
|
||||
# This is used to display the state of the SW in regard to fetch events.
|
||||
listeningForFetchEvents = Listening for fetch events.
|
||||
|
||||
# LOCALIZATION NOTE (notListeningForFetchEvents):
|
||||
# This is used to display the state of the SW in regard to fetch events.
|
||||
notListeningForFetchEvents = Not listening for fetch events.
|
||||
|
||||
# LOCALIZATION NOTE (addons):
|
||||
# This string is displayed as a header of the about:debugging#addons page.
|
||||
addons = Add-ons
|
||||
|
@ -53,6 +53,10 @@ let WorkerActor = protocol.ActorClassWithSpec(workerSpec, {
|
||||
if (this._dbg.type === Ci.nsIWorkerDebugger.TYPE_SERVICE) {
|
||||
let registration = this._getServiceWorkerRegistrationInfo();
|
||||
form.scope = registration.scope;
|
||||
let newestWorker = (registration.activeWorker ||
|
||||
registration.waitingWorker ||
|
||||
registration.installingWorker);
|
||||
form.fetch = newestWorker && newestWorker.handlesFetchEvents;
|
||||
}
|
||||
return form;
|
||||
},
|
||||
@ -229,6 +233,7 @@ let ServiceWorkerActor = protocol.ActorClassWithSpec(serviceWorkerSpec, {
|
||||
return {
|
||||
url: this._worker.scriptSpec,
|
||||
state: this._worker.state,
|
||||
fetch: this._worker.handlesFetchEvents
|
||||
};
|
||||
},
|
||||
|
||||
@ -287,6 +292,8 @@ protocol.ActorClassWithSpec(serviceWorkerRegistrationSpec, {
|
||||
let waitingWorker = this._waitingWorker.form();
|
||||
let activeWorker = this._activeWorker.form();
|
||||
|
||||
let newestWorker = (activeWorker || waitingWorker || installingWorker);
|
||||
|
||||
let isE10s = Services.appinfo.browserTabsRemoteAutostart;
|
||||
return {
|
||||
actor: this.actorID,
|
||||
@ -295,6 +302,7 @@ protocol.ActorClassWithSpec(serviceWorkerRegistrationSpec, {
|
||||
installingWorker,
|
||||
waitingWorker,
|
||||
activeWorker,
|
||||
fetch: newestWorker && newestWorker.fetch,
|
||||
// - In e10s: only active registrations are available.
|
||||
// - In non-e10s: registrations always have at least one worker, if the worker is
|
||||
// active, the registration is active.
|
||||
|
@ -45,6 +45,8 @@ interface nsIServiceWorkerInfo : nsISupports
|
||||
|
||||
readonly attribute nsIWorkerDebugger debugger;
|
||||
|
||||
readonly attribute bool handlesFetchEvents;
|
||||
|
||||
void attachDebugger();
|
||||
|
||||
void detachDebugger();
|
||||
|
@ -60,6 +60,15 @@ ServiceWorkerInfo::GetDebugger(nsIWorkerDebugger** aResult)
|
||||
return mServiceWorkerPrivate->GetDebugger(aResult);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ServiceWorkerInfo::GetHandlesFetchEvents(bool* aValue)
|
||||
{
|
||||
MOZ_ASSERT(aValue);
|
||||
AssertIsOnMainThread();
|
||||
*aValue = HandlesFetch();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
ServiceWorkerInfo::AttachDebugger()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user