Backed out changeset 29cdfd4dec23 (bug 1369209) for browser chrome failures on browser_ext_management.js. CLOSED TREE

This commit is contained in:
Cosmin Sabou 2018-08-23 22:29:36 +03:00
parent 1b7f123cfb
commit 54a6357287
6 changed files with 2 additions and 149 deletions

View File

@ -28,8 +28,6 @@ support-files =
file_inspectedwindow_reload_target.sjs file_inspectedwindow_reload_target.sjs
file_indexedDB.html file_indexedDB.html
file_serviceWorker.html file_serviceWorker.html
install_other-1.0-fx.xpi
install_theme-1.0-fx.xpi
webNav_createdTarget.html webNav_createdTarget.html
webNav_createdTargetSource.html webNav_createdTargetSource.html
webNav_createdTargetSource_subframe.html webNav_createdTargetSource_subframe.html
@ -107,7 +105,6 @@ skip-if = (verify && (os == 'linux' || os == 'mac'))
[browser_ext_incognito_views.js] [browser_ext_incognito_views.js]
[browser_ext_incognito_popup.js] [browser_ext_incognito_popup.js]
[browser_ext_lastError.js] [browser_ext_lastError.js]
[browser_ext_management.js]
[browser_ext_menus.js] [browser_ext_menus.js]
[browser_ext_menus_accesskey.js] [browser_ext_menus_accesskey.js]
[browser_ext_menus_activeTab.js] [browser_ext_menus_activeTab.js]

View File

@ -1,80 +0,0 @@
"use strict";
const BASE = "http://mochi.test:8888/browser/browser/components/extensions/test/browser/";
function waitForTransition(element, propertyName) {
return BrowserTestUtils.waitForEvent(element, "transitionend", false, event => {
return event.target == element && event.propertyName == propertyName;
});
}
add_task(async function test_management_install() {
await SpecialPowers.pushPrefEnv({set: [
["xpinstall.signatures.required", false],
]});
registerCleanupFunction(async () => {
await SpecialPowers.popPrefEnv();
});
let extension = ExtensionTestUtils.loadExtension({
manifest: {
browser_action: {
"browser_style": false,
},
permissions: ["management"],
},
background() {
let addons;
browser.test.onMessage.addListener((msg, init) => {
addons = init;
browser.test.sendMessage("ready");
});
browser.browserAction.onClicked.addListener(async () => {
try {
let {url, hash} = addons.shift();
browser.test.log(`Installing XPI from ${url} with hash ${hash || "missing"}`);
let {id} = await browser.management.install({url, hash});
let {type} = await browser.management.get(id);
browser.test.sendMessage("installed", {id, type});
} catch (e) {
browser.test.log(`management.install() throws ${e}`);
browser.test.sendMessage("failed", e.message);
}
});
},
});
let addons = [{
url: BASE + "install_theme-1.0-fx.xpi",
hash: "sha256:aa232d8391d82a9c1014364efbe1657ff6d8dfc88b3c71e99881b1f3843fdad3",
}, {
url: BASE + "install_other-1.0-fx.xpi",
}];
await extension.startup();
extension.sendMessage("addons", addons);
await extension.awaitMessage("ready");
// Test installing a static WE theme.
let transitionDone = waitForTransition(document.documentElement, "background-color");
clickBrowserAction(extension);
let {id, type} = await extension.awaitMessage("installed");
is(id, "tiger@persona.beard", "Static web extension theme installed");
is(type, "theme", "Extension type is correct");
await transitionDone;
let style = window.getComputedStyle(document.documentElement);
is(style.backgroundColor, "rgb(255, 165, 0)", "Background is the new black");
let addon = await AddonManager.getAddonByID("tiger@persona.beard");
await addon.uninstall();
// Test installing a standard WE.
clickBrowserAction(extension);
let error = await extension.awaitMessage("failed");
is(error, "Incompatible addon", "Standard web extension rejected");
await extension.unload();
});

View File

@ -187,28 +187,6 @@ this.management = class extends ExtensionAPI {
}); });
}, },
async install({url, hash}) {
let listener = {
onDownloadEnded(install) {
if (install.addon.appDisabled || install.addon.type !== "theme") {
install.cancel();
return false;
}
},
};
let install = await AddonManager.getInstallForURL(url, "application/x-xpinstall", hash);
install.addListener(listener);
try {
await install.install();
} catch (e) {
Cu.reportError(e);
throw new ExtensionError("Incompatible addon");
}
await install.addon.enable();
return {id: install.addon.id};
},
async getSelf() { async getSelf() {
let addon = await AddonManager.getAddonByID(extension.id); let addon = await AddonManager.getAddonByID(extension.id);
return getExtensionInfoForAddon(extension, addon); return getExtensionInfoForAddon(extension, addon);

View File

@ -44,7 +44,7 @@
}, },
{ {
"id": "ExtensionType", "id": "ExtensionType",
"description": "The type of this extension, 'extension' or 'theme'.", "description": "The type of this extension. Will always be 'extension'.",
"type": "string", "type": "string",
"enum": ["extension", "theme"] "enum": ["extension", "theme"]
}, },
@ -99,7 +99,7 @@
"optional": true "optional": true
}, },
"type": { "type": {
"description": "The type of this extension, 'extension' or 'theme'.", "description": "The type of this extension. Will always return 'extension'.",
"$ref": "ExtensionType" "$ref": "ExtensionType"
}, },
"homepageUrl": { "homepageUrl": {
@ -196,48 +196,6 @@
} }
] ]
}, },
{
"name": "install",
"type": "function",
"requireUserInput": true,
"permissions": ["management"],
"description": "Installs and enables a theme extension from the given url.",
"async": "callback",
"parameters": [
{
"name": "options",
"type": "object",
"properties": {
"url": {
"$ref": "manifest.HttpURL",
"description": "URL pointing to the XPI file on addons.mozilla.org or similar."
},
"hash": {
"type": "string",
"optional": true,
"pattern": "^(sha256|sha512):[0-9a-fA-F]{64,128}$",
"description": "A hash of the XPI file, using sha256 or stronger."
}
}
},
{
"name": "callback",
"type": "function",
"optional": true,
"parameters": [
{
"name": "result",
"type": "object",
"properties": {
"id": {
"$ref": "manifest.ExtensionID"
}
}
}
]
}
]
},
{ {
"name": "getSelf", "name": "getSelf",
"type": "function", "type": "function",