зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset b062b1682bbd (bug 1495855) for failures on browser_addons_debug_info.js. CLOSED TREE
This commit is contained in:
Родитель
785e828e8b
Коммит
ad070fb0ff
|
@ -0,0 +1,10 @@
|
|||
{
|
||||
"manifest_version": 2,
|
||||
"name": "test-devtools-webextension-nobg",
|
||||
"version": "1.0",
|
||||
"applications": {
|
||||
"gecko": {
|
||||
"id": "test-devtools-webextension-nobg@mozilla.org"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"manifest_version": 2,
|
||||
"name": "test-devtools-webextension-noid",
|
||||
"version": "1.0"
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
{
|
||||
"manifest_version": 2,
|
||||
"name": "test-devtools-webextension-unknown-prop",
|
||||
"version": "1.0",
|
||||
"applications": {
|
||||
"gecko": {
|
||||
"id": "test-devtools-webextension-unknown-prop@mozilla.org"
|
||||
}
|
||||
},
|
||||
"browser_actions": {
|
||||
"default_title": "WebExtension Popup Debugging",
|
||||
"default_popup": "popup.html"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/* eslint-env browser */
|
||||
/* global browser */
|
||||
|
||||
"use strict";
|
||||
|
||||
document.body.innerText = "Background Page Body Test Content";
|
||||
|
||||
// These functions are called from the following about:debugging tests:
|
||||
// - browser_addons_debug_webextension.js
|
||||
// - browser_addons_debug_webextension_popup.js
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
function myWebExtensionAddonFunction() {
|
||||
console.log("Background page function called", browser.runtime.getManifest());
|
||||
}
|
||||
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
function myWebExtensionShowPopup() {
|
||||
browser.test.sendMessage("readyForOpenPopup");
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"manifest_version": 2,
|
||||
"name": "test-devtools-webextension",
|
||||
"version": "1.0",
|
||||
"applications": {
|
||||
"gecko": {
|
||||
"id": "test-devtools-webextension@mozilla.org"
|
||||
}
|
||||
},
|
||||
"background": {
|
||||
"scripts": ["bg.js"]
|
||||
},
|
||||
"browser_action": {
|
||||
"default_title": "WebExtension Popup Debugging",
|
||||
"default_popup": "popup.html"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<script src="popup.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
Background Page Body Test Content
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,15 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
/* eslint-env browser */
|
||||
/* global browser */
|
||||
|
||||
"use strict";
|
||||
|
||||
// This function is called from the following about:debugging test:
|
||||
// browser_addons_debug_webextension.js
|
||||
//
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
function myWebExtensionPopupAddonFunction() {
|
||||
browser.test.sendMessage("popupPageFunctionCalled", browser.runtime.getManifest());
|
||||
}
|
|
@ -39,27 +39,15 @@ add_task(async function testWebExtension() {
|
|||
const { tab, document } = await openAboutDebugging("addons");
|
||||
|
||||
await waitForInitialAddonList(document);
|
||||
|
||||
const addonFile = ExtensionTestCommon.generateXPI({
|
||||
manifest: {
|
||||
name: addonName,
|
||||
applications: {
|
||||
gecko: {id: addonId},
|
||||
},
|
||||
},
|
||||
});
|
||||
registerCleanupFunction(() => addonFile.remove(false));
|
||||
|
||||
await installAddon({
|
||||
document,
|
||||
file: addonFile,
|
||||
path: "addons/test-devtools-webextension-nobg/manifest.json",
|
||||
name: addonName,
|
||||
isWebExtension: true
|
||||
});
|
||||
|
||||
const container = document.querySelector(`[data-addon-id="${addonId}"]`);
|
||||
|
||||
testFilePath(container, addonFile.path);
|
||||
testFilePath(container, "/test/addons/test-devtools-webextension-nobg/");
|
||||
|
||||
const extensionID = container.querySelector(".extension-id span");
|
||||
ok(extensionID.textContent === "test-devtools-webextension-nobg@mozilla.org");
|
||||
|
@ -80,17 +68,9 @@ add_task(async function testTemporaryWebExtension() {
|
|||
const { tab, document } = await openAboutDebugging("addons");
|
||||
|
||||
await waitForInitialAddonList(document);
|
||||
|
||||
const addonFile = ExtensionTestCommon.generateXPI({
|
||||
manifest: {
|
||||
name: addonName,
|
||||
},
|
||||
});
|
||||
registerCleanupFunction(() => addonFile.remove(false));
|
||||
|
||||
await installAddon({
|
||||
document,
|
||||
file: addonFile,
|
||||
path: "addons/test-devtools-webextension-noid/manifest.json",
|
||||
name: addonName,
|
||||
isWebExtension: true
|
||||
});
|
||||
|
@ -118,22 +98,9 @@ add_task(async function testUnknownManifestProperty() {
|
|||
const { tab, document } = await openAboutDebugging("addons");
|
||||
|
||||
await waitForInitialAddonList(document);
|
||||
|
||||
const addonFile = ExtensionTestCommon.generateXPI({
|
||||
manifest: {
|
||||
name: addonName,
|
||||
applications: {
|
||||
gecko: {id: addonId},
|
||||
},
|
||||
wrong_manifest_property_name: {
|
||||
}
|
||||
},
|
||||
});
|
||||
registerCleanupFunction(() => addonFile.remove(false));
|
||||
|
||||
await installAddon({
|
||||
document,
|
||||
file: addonFile,
|
||||
path: "addons/test-devtools-webextension-unknown-prop/manifest.json",
|
||||
name: addonName,
|
||||
isWebExtension: true
|
||||
});
|
||||
|
@ -146,7 +113,7 @@ add_task(async function testUnknownManifestProperty() {
|
|||
|
||||
const messages = container.querySelectorAll(".addon-target-message");
|
||||
ok(messages.length === 1, "there is one message");
|
||||
ok(messages[0].textContent.match(/Error processing wrong_manifest_property_name/),
|
||||
ok(messages[0].textContent.match(/Error processing browser_actions/),
|
||||
"the message is helpful");
|
||||
ok(messages[0].classList.contains("addon-target-warning-message"),
|
||||
"the message is a warning");
|
||||
|
|
|
@ -13,6 +13,7 @@ requestLongerTimeout(2);
|
|||
|
||||
const ADDON_ID = "test-devtools-webextension@mozilla.org";
|
||||
const ADDON_NAME = "test-devtools-webextension";
|
||||
const ADDON_MANIFEST_PATH = "addons/test-devtools-webextension/manifest.json";
|
||||
|
||||
const {
|
||||
BrowserToolboxProcess
|
||||
|
@ -24,25 +25,9 @@ const {
|
|||
* has a working webconsole with the background page as default target;
|
||||
*/
|
||||
add_task(async function testWebExtensionsToolboxWebConsole() {
|
||||
const addonFile = ExtensionTestCommon.generateXPI({
|
||||
background: function() {
|
||||
window.myWebExtensionAddonFunction = function() {
|
||||
console.log("Background page function called",
|
||||
this.browser.runtime.getManifest());
|
||||
};
|
||||
},
|
||||
manifest: {
|
||||
name: ADDON_NAME,
|
||||
applications: {
|
||||
gecko: {id: ADDON_ID},
|
||||
},
|
||||
},
|
||||
});
|
||||
registerCleanupFunction(() => addonFile.remove(false));
|
||||
|
||||
const {
|
||||
tab, document, debugBtn,
|
||||
} = await setupTestAboutDebuggingWebExtension(ADDON_NAME, addonFile);
|
||||
} = await setupTestAboutDebuggingWebExtension(ADDON_NAME, ADDON_MANIFEST_PATH);
|
||||
|
||||
// Be careful, this JS function is going to be executed in the addon toolbox,
|
||||
// which lives in another process. So do not try to use any scope variable!
|
||||
|
|
|
@ -12,6 +12,7 @@ requestLongerTimeout(2);
|
|||
|
||||
const ADDON_ID = "test-devtools-webextension@mozilla.org";
|
||||
const ADDON_NAME = "test-devtools-webextension";
|
||||
const ADDON_PATH = "addons/test-devtools-webextension/manifest.json";
|
||||
|
||||
const {
|
||||
BrowserToolboxProcess
|
||||
|
@ -23,22 +24,9 @@ const {
|
|||
* background page as default target;
|
||||
*/
|
||||
add_task(async function testWebExtensionsToolboxInspector() {
|
||||
const addonFile = ExtensionTestCommon.generateXPI({
|
||||
background: function() {
|
||||
document.body.innerText = "Background Page Body Test Content";
|
||||
},
|
||||
manifest: {
|
||||
name: ADDON_NAME,
|
||||
applications: {
|
||||
gecko: {id: ADDON_ID},
|
||||
},
|
||||
},
|
||||
});
|
||||
registerCleanupFunction(() => addonFile.remove(false));
|
||||
|
||||
const {
|
||||
tab, document, debugBtn,
|
||||
} = await setupTestAboutDebuggingWebExtension(ADDON_NAME, addonFile);
|
||||
} = await setupTestAboutDebuggingWebExtension(ADDON_NAME, ADDON_PATH);
|
||||
|
||||
// Be careful, this JS function is going to be executed in the addon toolbox,
|
||||
// which lives in another process. So do not try to use any scope variable!
|
||||
|
|
|
@ -12,6 +12,7 @@ requestLongerTimeout(2);
|
|||
|
||||
const ADDON_NOBG_ID = "test-devtools-webextension-nobg@mozilla.org";
|
||||
const ADDON_NOBG_NAME = "test-devtools-webextension-nobg";
|
||||
const ADDON_NOBG_PATH = "addons/test-devtools-webextension-nobg/manifest.json";
|
||||
|
||||
const {
|
||||
BrowserToolboxProcess
|
||||
|
@ -25,19 +26,9 @@ const {
|
|||
* webextension context);
|
||||
*/
|
||||
add_task(async function testWebExtensionsToolboxNoBackgroundPage() {
|
||||
const addonFile = ExtensionTestCommon.generateXPI({
|
||||
manifest: {
|
||||
name: ADDON_NOBG_NAME,
|
||||
applications: {
|
||||
gecko: {id: ADDON_NOBG_ID},
|
||||
},
|
||||
},
|
||||
});
|
||||
registerCleanupFunction(() => addonFile.remove(false));
|
||||
|
||||
const {
|
||||
tab, document, debugBtn,
|
||||
} = await setupTestAboutDebuggingWebExtension(ADDON_NOBG_NAME, addonFile);
|
||||
} = await setupTestAboutDebuggingWebExtension(ADDON_NOBG_NAME, ADDON_NOBG_PATH);
|
||||
|
||||
// Be careful, this JS function is going to be executed in the addon toolbox,
|
||||
// which lives in another process. So do not try to use any scope variable!
|
||||
|
@ -45,37 +36,41 @@ add_task(async function testWebExtensionsToolboxNoBackgroundPage() {
|
|||
.getService(Ci.nsIEnvironment);
|
||||
const testScript = function() {
|
||||
/* eslint-disable no-undef */
|
||||
toolbox.selectTool("inspector").then(async inspector => {
|
||||
const nodeActor = await inspector.walker.querySelector(
|
||||
inspector.walker.rootNode, "body");
|
||||
toolbox.selectTool("inspector")
|
||||
.then(inspector => {
|
||||
return inspector.walker.querySelector(inspector.walker.rootNode, "body");
|
||||
})
|
||||
.then((nodeActor) => {
|
||||
if (!nodeActor) {
|
||||
throw new Error("nodeActor not found");
|
||||
}
|
||||
|
||||
if (!nodeActor) {
|
||||
throw new Error("nodeActor not found");
|
||||
}
|
||||
dump("Got a nodeActor\n");
|
||||
|
||||
if (!(nodeActor.inlineTextChild)) {
|
||||
throw new Error("inlineTextChild not found");
|
||||
}
|
||||
if (!(nodeActor.inlineTextChild)) {
|
||||
throw new Error("inlineTextChild not found");
|
||||
}
|
||||
|
||||
dump("Got a nodeActor with an inline text child\n");
|
||||
dump("Got a nodeActor with an inline text child\n");
|
||||
|
||||
const expectedValue = "Your addon does not have any document opened yet.";
|
||||
const actualValue = nodeActor.inlineTextChild._form.nodeValue;
|
||||
const expectedValue = "Your addon does not have any document opened yet.";
|
||||
const actualValue = nodeActor.inlineTextChild._form.nodeValue;
|
||||
|
||||
if (actualValue !== expectedValue) {
|
||||
throw new Error(
|
||||
`mismatched inlineTextchild value: "${actualValue}" !== "${expectedValue}"`
|
||||
);
|
||||
}
|
||||
if (actualValue !== expectedValue) {
|
||||
throw new Error(
|
||||
`mismatched inlineTextchild value: "${actualValue}" !== "${expectedValue}"`
|
||||
);
|
||||
}
|
||||
|
||||
dump("Got the expected inline text content in the selected node\n");
|
||||
|
||||
await toolbox.destroy();
|
||||
}).catch((error) => {
|
||||
dump("Error while running code in the browser toolbox process:\n");
|
||||
dump(error + "\n");
|
||||
dump("stack:\n" + error.stack + "\n");
|
||||
});
|
||||
dump("Got the expected inline text content in the selected node\n");
|
||||
return Promise.resolve();
|
||||
})
|
||||
.then(() => toolbox.destroy())
|
||||
.catch((error) => {
|
||||
dump("Error while running code in the browser toolbox process:\n");
|
||||
dump(error + "\n");
|
||||
dump("stack:\n" + error.stack + "\n");
|
||||
});
|
||||
/* eslint-enable no-undef */
|
||||
};
|
||||
env.set("MOZ_TOOLBOX_TEST_SCRIPT", "new " + testScript);
|
||||
|
|
|
@ -12,6 +12,7 @@ requestLongerTimeout(2);
|
|||
|
||||
const ADDON_ID = "test-devtools-webextension@mozilla.org";
|
||||
const ADDON_NAME = "test-devtools-webextension";
|
||||
const ADDON_MANIFEST_PATH = "addons/test-devtools-webextension/manifest.json";
|
||||
|
||||
const {
|
||||
BrowserToolboxProcess
|
||||
|
@ -41,46 +42,6 @@ function makeWidgetId(id) {
|
|||
}
|
||||
|
||||
add_task(async function testWebExtensionsToolboxSwitchToPopup() {
|
||||
const addonFile = ExtensionTestCommon.generateXPI({
|
||||
background: function() {
|
||||
const {browser} = this;
|
||||
window.myWebExtensionShowPopup = function() {
|
||||
browser.test.sendMessage("readyForOpenPopup");
|
||||
};
|
||||
},
|
||||
manifest: {
|
||||
name: ADDON_NAME,
|
||||
applications: {
|
||||
gecko: {id: ADDON_ID},
|
||||
},
|
||||
browser_action: {
|
||||
default_title: "WebExtension Popup Debugging",
|
||||
default_popup: "popup.html",
|
||||
},
|
||||
},
|
||||
files: {
|
||||
"popup.html": `<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<script src="popup.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
Background Page Body Test Content
|
||||
</body>
|
||||
</html>
|
||||
`,
|
||||
"popup.js": function() {
|
||||
const {browser} = this;
|
||||
window.myWebExtensionPopupAddonFunction = function() {
|
||||
browser.test.sendMessage("popupPageFunctionCalled",
|
||||
browser.runtime.getManifest());
|
||||
};
|
||||
},
|
||||
},
|
||||
});
|
||||
registerCleanupFunction(() => addonFile.remove(false));
|
||||
|
||||
let onReadyForOpenPopup;
|
||||
let onPopupCustomMessage;
|
||||
|
||||
|
@ -120,7 +81,7 @@ add_task(async function testWebExtensionsToolboxSwitchToPopup() {
|
|||
|
||||
const {
|
||||
tab, document, debugBtn,
|
||||
} = await setupTestAboutDebuggingWebExtension(ADDON_NAME, addonFile);
|
||||
} = await setupTestAboutDebuggingWebExtension(ADDON_NAME, ADDON_MANIFEST_PATH);
|
||||
|
||||
// Be careful, this JS function is going to be executed in the addon toolbox,
|
||||
// which lives in another process. So do not try to use any scope variable!
|
||||
|
|
|
@ -44,20 +44,10 @@ add_task(async function removeWebextension() {
|
|||
const { tab, document } = await openAboutDebugging("addons");
|
||||
await waitForInitialAddonList(document);
|
||||
|
||||
const addonFile = ExtensionTestCommon.generateXPI({
|
||||
manifest: {
|
||||
name: addonName,
|
||||
applications: {
|
||||
gecko: {id: addonID},
|
||||
},
|
||||
},
|
||||
});
|
||||
registerCleanupFunction(() => addonFile.remove(false));
|
||||
|
||||
// Install this add-on, and verify that it appears in the about:debugging UI
|
||||
await installAddon({
|
||||
document,
|
||||
file: addonFile,
|
||||
path: "addons/test-devtools-webextension/manifest.json",
|
||||
name: addonName,
|
||||
isWebExtension: true,
|
||||
});
|
||||
|
|
|
@ -14,7 +14,6 @@ Services.scriptloader.loadSubScript(
|
|||
|
||||
const { AddonManager } = ChromeUtils.import("resource://gre/modules/AddonManager.jsm", {});
|
||||
const { Management } = ChromeUtils.import("resource://gre/modules/Extension.jsm", {});
|
||||
const { ExtensionTestCommon } = ChromeUtils.import("resource://testing-common/ExtensionTestCommon.jsm", {});
|
||||
|
||||
async function openAboutDebugging(page, win) {
|
||||
info("opening about:debugging");
|
||||
|
@ -166,16 +165,12 @@ function getTabList(document) {
|
|||
document.querySelector("#tabs.targets");
|
||||
}
|
||||
|
||||
async function installAddon({document, path, file, name, isWebExtension}) {
|
||||
async function installAddon({document, path, name, isWebExtension}) {
|
||||
// Mock the file picker to select a test addon
|
||||
const MockFilePicker = SpecialPowers.MockFilePicker;
|
||||
MockFilePicker.init(window);
|
||||
if (path) {
|
||||
file = getSupportsFile(path);
|
||||
MockFilePicker.setFiles([file.file]);
|
||||
} else {
|
||||
MockFilePicker.setFiles([file]);
|
||||
}
|
||||
const file = getSupportsFile(path);
|
||||
MockFilePicker.setFiles([file.file]);
|
||||
|
||||
let onAddonInstalled;
|
||||
|
||||
|
@ -346,7 +341,7 @@ function waitForDelayedStartupFinished(win) {
|
|||
/**
|
||||
* open the about:debugging page and install an addon
|
||||
*/
|
||||
async function setupTestAboutDebuggingWebExtension(name, file) {
|
||||
async function setupTestAboutDebuggingWebExtension(name, path) {
|
||||
await new Promise(resolve => {
|
||||
const options = {"set": [
|
||||
// Force enabling of addons debugging
|
||||
|
@ -365,7 +360,7 @@ async function setupTestAboutDebuggingWebExtension(name, file) {
|
|||
|
||||
await installAddon({
|
||||
document,
|
||||
file,
|
||||
path,
|
||||
name,
|
||||
isWebExtension: true,
|
||||
});
|
||||
|
|
Загрузка…
Ссылка в новой задаче