mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-04-02 04:22:56 +00:00
Bug 1651630 - Part 1: Allow start button to work regardless of debugger pref r=jdescottes,fluent-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D83482
This commit is contained in:
parent
9a1f31493d
commit
295e3aec7c
@ -74,11 +74,6 @@ class Worker extends PureComponent {
|
||||
}
|
||||
|
||||
start() {
|
||||
if (!this.props.isDebugEnabled) {
|
||||
console.log("Service workers cannot be started in multi-e10s");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!this.isActive() || this.isRunning()) {
|
||||
console.log("Running or inactive service workers cannot be started");
|
||||
return;
|
||||
@ -156,27 +151,17 @@ class Worker extends PureComponent {
|
||||
}
|
||||
|
||||
renderStartButton() {
|
||||
const { isDebugEnabled } = this.props;
|
||||
|
||||
// avoid rendering the button at all for workers that are either running,
|
||||
// or in a state that prevents them from starting (like waiting)
|
||||
if (this.isRunning() || !this.isActive()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const isDisabled = !isDebugEnabled;
|
||||
return Localized(
|
||||
{
|
||||
id: "serviceworker-worker-start2",
|
||||
// The localized title is only displayed if the debug link is disabled.
|
||||
attrs: {
|
||||
title: !isDisabled,
|
||||
},
|
||||
},
|
||||
{ id: "serviceworker-worker-start3" },
|
||||
UIButton({
|
||||
onClick: this.start,
|
||||
className: `js-start-button`,
|
||||
disabled: isDisabled,
|
||||
size: "micro",
|
||||
})
|
||||
);
|
||||
|
@ -31,8 +31,6 @@ support-files =
|
||||
# Worker-related tests
|
||||
[browser_application_panel_debug-service-worker.js]
|
||||
skip-if = debug || asan || !serviceworker_e10s # Bug 1559591, 1575578, 1588154
|
||||
[browser_application_panel_disable-start-service-worker.js]
|
||||
skip-if = (os == 'linux' && asan) || debug # Bug 1559487, 1559591
|
||||
[browser_application_panel_list-domain-workers.js]
|
||||
skip-if = debug # Bug 1559591
|
||||
[browser_application_panel_list-multiple-workers-same-registration.js]
|
||||
|
@ -1,51 +0,0 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
const TAB_URL = URL_ROOT + "resources/service-workers/simple.html";
|
||||
|
||||
/**
|
||||
* Tests that Start button is disabled for service workers, when they cannot be debugged
|
||||
*/
|
||||
add_task(async function() {
|
||||
await enableApplicationPanel();
|
||||
|
||||
// Setting a low idle_timeout and idle_extended_timeout will allow the service worker
|
||||
// to reach the STOPPED state quickly, which will allow us to test the start button.
|
||||
// The default value is 30000 milliseconds.
|
||||
info("Set a low service worker idle timeout");
|
||||
await pushPref("dom.serviceWorkers.idle_timeout", 1000);
|
||||
await pushPref("dom.serviceWorkers.idle_extended_timeout", 1000);
|
||||
|
||||
// disable sw debugging
|
||||
info("Disable service worker debugging");
|
||||
await pushPref(
|
||||
"devtools.debugger.features.windowless-service-workers",
|
||||
false
|
||||
);
|
||||
|
||||
const { panel, tab, target } = await openNewTabAndApplicationPanel(TAB_URL);
|
||||
const doc = panel.panelWin.document;
|
||||
|
||||
selectPage(panel, "service-workers");
|
||||
|
||||
await waitForWorkerRegistration(tab);
|
||||
|
||||
info("Wait until the service worker appears in the application panel");
|
||||
await waitUntil(() => getWorkerContainers(doc).length === 1);
|
||||
|
||||
info("Wait until the start button is displayed");
|
||||
const container = getWorkerContainers(doc)[0];
|
||||
await waitUntil(() => container.querySelector(".js-start-button"));
|
||||
ok(
|
||||
container.querySelector(".js-start-button").disabled,
|
||||
"Start button is disabled"
|
||||
);
|
||||
|
||||
await unregisterAllWorkers(target.client, doc);
|
||||
|
||||
// close the tab
|
||||
info("Closing the tab.");
|
||||
await BrowserTestUtils.removeTab(tab);
|
||||
});
|
@ -167,16 +167,10 @@ exports[`Worker Renders the expected snapshot for a stopped worker 1`] = `
|
||||
</span>
|
||||
|
||||
<Localized
|
||||
attrs={
|
||||
Object {
|
||||
"title": true,
|
||||
}
|
||||
}
|
||||
id="serviceworker-worker-start2"
|
||||
id="serviceworker-worker-start3"
|
||||
>
|
||||
<UIButton
|
||||
className="js-start-button"
|
||||
disabled={false}
|
||||
onClick={[Function]}
|
||||
size="micro"
|
||||
/>
|
||||
|
@ -56,12 +56,31 @@ describe("Worker", () => {
|
||||
expect(wrapper.find(".js-worker-status").text()).toBe(
|
||||
"serviceworker-worker-status-stopped"
|
||||
);
|
||||
// check that Start button is not available
|
||||
// check that Start button is available
|
||||
expect(wrapper.find(".js-start-button")).toHaveLength(1);
|
||||
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("Renders the start button even if debugging workers is disabled", () => {
|
||||
const store = setupStore({});
|
||||
|
||||
const wrapper = shallow(
|
||||
Worker({
|
||||
isDebugEnabled: false,
|
||||
worker: WORKER_STOPPED,
|
||||
store,
|
||||
})
|
||||
).dive();
|
||||
|
||||
// ensure proper status
|
||||
expect(wrapper.find(".js-worker-status").text()).toBe(
|
||||
"serviceworker-worker-status-stopped"
|
||||
);
|
||||
// check that Start button is available
|
||||
expect(wrapper.find(".js-start-button")).toHaveLength(1);
|
||||
});
|
||||
|
||||
it("Renders the expected snapshot for a non-active worker", () => {
|
||||
const store = setupStore({});
|
||||
|
||||
|
@ -33,8 +33,7 @@ serviceworker-worker-debug-forbidden = Debug
|
||||
|
||||
# Text for the start link displayed for a registered but not running Service Worker.
|
||||
# Clicking on the link will attempt to start the service worker.
|
||||
serviceworker-worker-start2 = Start
|
||||
.title = Can only start service workers if multi e10s is disabled
|
||||
serviceworker-worker-start3 = Start
|
||||
|
||||
# Text displayed for the updated time of the service worker. The <time> element will
|
||||
# display the last update time of the service worker script.
|
||||
|
Loading…
x
Reference in New Issue
Block a user