Bug 1500332 - Hide connection prompt in This Firefox page. r=jdescottes,daisuke

Differential Revision: https://phabricator.services.mozilla.com/D13075

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Belén Albeza 2018-12-05 13:44:47 +00:00
Родитель 1fc714c017
Коммит 15cf234f41
5 изменённых файлов: 79 добавлений и 13 удалений

Просмотреть файл

@ -25,7 +25,7 @@ const TemporaryExtensionInstaller =
const WorkerDetail = createFactory(require("./debugtarget/WorkerDetail"));
const Actions = require("../actions/index");
const { DEBUG_TARGET_PANE, PAGE_TYPES } = require("../constants");
const { DEBUG_TARGET_PANE, PAGE_TYPES, RUNTIMES } = require("../constants");
const {
getCurrentConnectionPromptSetting,
@ -98,6 +98,7 @@ class RuntimePage extends PureComponent {
dispatch,
installedExtensions,
otherWorkers,
runtimeId,
runtimeInfo,
serviceWorkers,
sharedWorkers,
@ -111,12 +112,17 @@ class RuntimePage extends PureComponent {
return null;
}
// do not show the connection prompt setting in 'This Firefox'
const shallShowPromptSetting = runtimeId !== RUNTIMES.THIS_FIREFOX;
return dom.article(
{
className: "page js-runtime-page",
},
RuntimeInfo(runtimeInfo),
this.renderConnectionPromptSetting(),
shallShowPromptSetting
? this.renderConnectionPromptSetting()
: null,
isSupportedDebugTargetPane(runtimeInfo.type, DEBUG_TARGET_PANE.TEMPORARY_EXTENSION)
? TemporaryExtensionInstaller({ dispatch })
: null,

Просмотреть файл

@ -31,6 +31,7 @@ skip-if = (os == 'linux' && bits == 32) # ADB start() fails on linux 32, see Bug
[browser_aboutdebugging_navigate.js]
[browser_aboutdebugging_persist_connection.js]
[browser_aboutdebugging_routes.js]
[browser_aboutdebugging_runtime_connection-prompt.js]
[browser_aboutdebugging_select_network_runtime.js]
[browser_aboutdebugging_sidebar_network_runtimes.js]
[browser_aboutdebugging_sidebar_usb_runtime.js]

Просмотреть файл

@ -3,38 +3,55 @@
"use strict";
/* import-globals-from head-mocks.js */
Services.scriptloader.loadSubScript(
CHROME_URL_ROOT + "head-mocks.js", this);
/**
* Check whether can toggle enable/disable connection prompt setting.
*/
add_task(async function() {
// enable USB devices mocks
const mocks = new Mocks();
const runtime = mocks.createUSBRuntime("1337id", {
deviceName: "Fancy Phone",
name: "Lorem ipsum",
});
info("Set initial state for test");
await pushPref("devtools.debugger.prompt-connection", true);
// open a remote runtime page
const { document, tab } = await openAboutDebugging();
mocks.emitUSBUpdate();
await connectToRuntime("Fancy Phone", document);
await selectRuntime("Fancy Phone", "Lorem ipsum", document);
info("Check whether connection prompt toggle button exists");
const connectionPromptToggleButton =
let connectionPromptToggleButton =
document.querySelector(".js-connection-prompt-toggle-button");
ok(connectionPromptToggleButton, "Toggle button existed");
await waitUntil(() => connectionPromptToggleButton.textContent.includes("Disable"));
ok(connectionPromptToggleButton.textContent.includes("Disable"),
"Toggle button shows 'Disable'");
info("Click on the toggle button");
connectionPromptToggleButton =
document.querySelector(".js-connection-prompt-toggle-button");
connectionPromptToggleButton.click();
info("Wait until the toggle button text is updated");
await waitUntil(() => connectionPromptToggleButton.textContent.includes("Enable"));
info("Check the preference");
is(Services.prefs.getBoolPref("devtools.debugger.prompt-connection"),
false,
"The preference should be updated");
const disabledPref = runtime.getPreference("devtools.debugger.prompt-connection");
is(disabledPref, false, "The preference should be updated");
info("Click on the toggle button again");
connectionPromptToggleButton.click();
info("Wait until the toggle button text is updated");
await waitUntil(() => connectionPromptToggleButton.textContent.includes("Disable"));
info("Check the preference");
is(Services.prefs.getBoolPref("devtools.debugger.prompt-connection"),
true,
"The preference should be updated");
const enabledPref = runtime.getPreference("devtools.debugger.prompt-connection");
is(enabledPref, true, "The preference should be updated");
await removeTab(tab);
});

Просмотреть файл

@ -0,0 +1,36 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/* import-globals-from head-mocks.js */
Services.scriptloader.loadSubScript(
CHROME_URL_ROOT + "head-mocks.js", this);
/**
* Test that remote runtimes show the connection prompt,
* but it's hidden in 'This Firefox'
*/
add_task(async function() {
// enable USB devices mocks
const mocks = new Mocks();
mocks.createUSBRuntime("1337id", {
deviceName: "Fancy Phone",
name: "Lorem ipsum",
});
const { document, tab } = await openAboutDebugging();
info("Checking This Firefox");
ok(!document.querySelector(".js-connection-prompt-toggle-button"),
"This Firefox does not contain the connection prompt button");
info("Checking a USB runtime");
mocks.emitUSBUpdate();
await connectToRuntime("Fancy Phone", document);
await selectRuntime("Fancy Phone", "Lorem ipsum", document);
ok(!!document.querySelector(".js-connection-prompt-toggle-button"),
"Runtime contains the connection prompt button");
await removeTab(tab);
});

Просмотреть файл

@ -26,6 +26,7 @@ function createClientMock() {
// add a reference to the internal event emitter so that consumers can fire client
// events.
_eventEmitter: eventEmitter,
_preferences: {},
addOneTimeListener: (evt, listener) => {
eventEmitter.once(evt, listener);
},
@ -55,7 +56,10 @@ function createClientMock() {
// no-op
getDeviceDescription: () => {},
// Return default preference value or null if no match.
getPreference: (prefName) => {
getPreference: function(prefName) {
if (prefName in this._preferences) {
return this._preferences[prefName];
}
if (prefName in DEFAULT_PREFERENCES) {
return DEFAULT_PREFERENCES[prefName];
}
@ -71,8 +75,10 @@ function createClientMock() {
serviceWorkers: [],
sharedWorkers: [],
}),
// no-op
setPreference: () => {},
// stores the preference locally (doesn't update about:config)
setPreference: function(prefName, value) {
this._preferences[prefName] = value;
},
};
}