Skip to content

Commit

Permalink
Backed out 15 changesets (bug 1358846, bug 1356826) for talos error. …
Browse files Browse the repository at this point in the history
…a=backout

Backed out changeset 96ea13bb00c5 (bug 1358846)
Backed out changeset b533d7f9b9c2 (bug 1358846)
Backed out changeset 7dcb80a051a3 (bug 1358846)
Backed out changeset 26825f1e33dd (bug 1358846)
Backed out changeset 98b57ff82a54 (bug 1358846)
Backed out changeset b9088593e34f (bug 1358846)
Backed out changeset cb2518673c56 (bug 1358846)
Backed out changeset 889c487a5d41 (bug 1358846)
Backed out changeset 459b36092b7a (bug 1356826)
Backed out changeset c861e23ec8ef (bug 1356826)
Backed out changeset d47998fa24cd (bug 1356826)
Backed out changeset b02e89c67132 (bug 1356826)
Backed out changeset c46fed6e4f6a (bug 1356826)
Backed out changeset 237268e3d9d2 (bug 1356826)
Backed out changeset 527435fc20db (bug 1356826)
  • Loading branch information
IrisHsiao committed May 12, 2017
1 parent fcd9a55 commit 6559420
Show file tree
Hide file tree
Showing 77 changed files with 3,345 additions and 2,651 deletions.
1 change: 0 additions & 1 deletion addon-sdk/source/test/addons/jetpack-addon.ini
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[addon-manager.xpi]
[author-email.xpi]
[child_process.xpi]
skip-if = true
[chrome.xpi]
[content-permissions.xpi]
[content-script-messages-latency.xpi]
Expand Down
2 changes: 0 additions & 2 deletions browser/app/profile/firefox.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@ pref("extensions.screenshots.system-disabled", true);
// Disable add-ons that are not installed by the user in all scopes by default.
// See the SCOPE constants in AddonManager.jsm for values to use here.
pref("extensions.autoDisableScopes", 15);
// Scopes to scan for changes at startup.
pref("extensions.startupScanScopes", 0);

// This is where the profiler WebExtension API will look for breakpad symbols.
// NOTE: deliberately http right now since https://symbols.mozilla.org is not supported.
Expand Down
6 changes: 0 additions & 6 deletions browser/base/content/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -1143,11 +1143,6 @@ addEventListener("DOMContentLoaded", function onDCL() {
gBrowser.updateBrowserRemoteness(initBrowser, gMultiProcessBrowser);
});

let _resolveDelayedStartup;
var delayedStartupPromise = new Promise(resolve => {
_resolveDelayedStartup = resolve;
});

var gBrowserInit = {
delayedStartupFinished: false,

Expand Down Expand Up @@ -1624,7 +1619,6 @@ var gBrowserInit = {

this.delayedStartupFinished = true;

_resolveDelayedStartup();
Services.obs.notifyObservers(window, "browser-delayed-startup-finished");
TelemetryTimestamps.add("delayedStartupFinished");
},
Expand Down
178 changes: 126 additions & 52 deletions browser/base/content/test/webextensions/browser_extension_sideloading.js
Original file line number Diff line number Diff line change
@@ -1,89 +1,155 @@
const {AddonManagerPrivate} = Cu.import("resource://gre/modules/AddonManager.jsm", {});

const {AddonTestUtils} = Cu.import("resource://testing-common/AddonTestUtils.jsm", {});
// MockAddon mimics the AddonInternal interface and MockProvider implements
// just enough of the AddonManager provider interface to make it look like
// we have sideloaded webextensions so the sideloading flow can be tested.

// MockAddon -> callback
let setCallbacks = new Map();

class MockAddon {
constructor(props) {
this._userDisabled = false;
this.pendingOperations = 0;
this.type = "extension";

for (let name in props) {
if (name == "userDisabled") {
this._userDisabled = props[name];
}
this[name] = props[name];
}
}

AddonTestUtils.initMochitest(this);
markAsSeen() {
this.seen = true;
}

async function createWebExtension(details) {
let options = {
manifest: {
applications: {gecko: {id: details.id}},
get userDisabled() {
return this._userDisabled;
}

name: details.name,
set userDisabled(val) {
this._userDisabled = val;
AddonManagerPrivate.callAddonListeners(val ? "onDisabled" : "onEnabled", this);
let fn = setCallbacks.get(this);
if (fn) {
setCallbacks.delete(this);
fn(val);
}
return val;
}

permissions: details.permissions,
},
};
get permissions() {
return this._userDisabled ? AddonManager.PERM_CAN_ENABLE : AddonManager.PERM_CAN_DISABLE;
}
}

if (details.iconURL) {
options.manifest.icons = {"64": details.iconURL};
class MockProvider {
constructor(...addons) {
this.addons = new Set(addons);
}

let xpi = AddonTestUtils.createTempWebExtensionFile(options);
startup() { }
shutdown() { }

getAddonByID(id, callback) {
for (let addon of this.addons) {
if (addon.id == id) {
callback(addon);
return;
}
}
callback(null);
}

await AddonTestUtils.manuallyInstall(xpi);
getAddonsByTypes(types, callback) {
let addons = [];
if (!types || types.includes("extension")) {
addons = [...this.addons];
}
callback(addons);
}
}

async function createXULExtension(details) {
let xpi = AddonTestUtils.createTempXPIFile({
"install.rdf": {
id: details.id,
name: details.name,
version: "0.1",
targetApplications: [{
id: "[email protected]",
minVersion: "0",
maxVersion: "*",
}],
},
function promiseSetDisabled(addon) {
return new Promise(resolve => {
setCallbacks.set(addon, resolve);
});

await AddonTestUtils.manuallyInstall(xpi);
}

let cleanup;

add_task(function* test_sideloading() {
add_task(function* () {
// ICON_URL wouldn't ever appear as an actual webextension icon, but
// we're just mocking out the addon here, so all we care about is that
// that it propagates correctly to the popup.
const ICON_URL = "chrome://mozapps/skin/extensions/category-extensions.svg";
const DEFAULT_ICON_URL = "chrome://mozapps/skin/extensions/extensionGeneric.svg";

yield SpecialPowers.pushPrefEnv({
set: [
["xpinstall.signatures.required", false],
["extensions.autoDisableScopes", 15],
["extensions.ui.ignoreUnsigned", true],
],
});

const ID1 = "[email protected]";
yield createWebExtension({
let mock1 = new MockAddon({
id: ID1,
name: "Test 1",
userDisabled: true,
permissions: ["history", "https://*/*"],
iconURL: "foo-icon.png",
seen: false,
userPermissions: {
permissions: ["history"],
origins: ["https://*/*"],
},
iconURL: ICON_URL,
});

const ID2 = "[email protected]";
yield createXULExtension({
let mock2 = new MockAddon({
id: ID2,
name: "Test 2",
userDisabled: true,
seen: false,
userPermissions: {
permissions: [],
origins: [],
},
});

const ID3 = "[email protected]";
yield createWebExtension({
let mock3 = new MockAddon({
id: ID3,
name: "Test 3",
permissions: ["<all_urls>"],
isWebExtension: true,
userDisabled: true,
seen: false,
userPermissions: {
permissions: [],
origins: ["<all_urls>"],
}
});

const ID4 = "[email protected]";
yield createWebExtension({
let mock4 = new MockAddon({
id: ID4,
name: "Test 4",
permissions: ["<all_urls>"],
isWebExtension: true,
userDisabled: true,
seen: false,
userPermissions: {
permissions: [],
origins: ["<all_urls>"],
}
});

let provider = new MockProvider(mock1, mock2, mock3, mock4);
AddonManagerPrivate.registerProvider(provider, [{
id: "extension",
name: "Extensions",
uiPriority: 4000,
flags: AddonManager.TYPE_UI_VIEW_LIST |
AddonManager.TYPE_SUPPORTS_UNDO_RESTARTLESS_UNINSTALL,
}]);

testCleanup = async function() {
AddonManagerPrivate.unregisterProvider(provider);

// clear out ExtensionsUI state about sideloaded extensions so
// subsequent tests don't get confused.
ExtensionsUI.sideloaded.clear();
Expand Down Expand Up @@ -137,13 +203,17 @@ add_task(function* test_sideloading() {
is(win.gViewController.currentViewId, VIEW, "about:addons is at extensions list");

// Check the contents of the notification, then choose "Cancel"
checkNotification(panel, /\/foo-icon\.png$/, [
checkNotification(panel, ICON_URL, [
["webextPerms.hostDescription.allUrls"],
["webextPerms.description.history"],
]);

let disablePromise = promiseSetDisabled(mock1);
panel.secondaryButton.click();

let value = yield disablePromise;
is(value, true, "Addon should remain disabled");

let [addon1, addon2, addon3, addon4] = yield AddonManager.getAddonsByIDs([ID1, ID2, ID3, ID4]);
ok(addon1.seen, "Addon should be marked as seen");
is(addon1.userDisabled, true, "Addon 1 should still be disabled");
Expand Down Expand Up @@ -175,8 +245,12 @@ add_task(function* test_sideloading() {
checkNotification(panel, DEFAULT_ICON_URL, []);

// This time accept the install.
disablePromise = promiseSetDisabled(mock2);
panel.button.click();

value = yield disablePromise;
is(value, false, "Addon should be set to enabled");

[addon1, addon2, addon3, addon4] = yield AddonManager.getAddonsByIDs([ID1, ID2, ID3, ID4]);
is(addon1.userDisabled, true, "Addon 1 should still be disabled");
is(addon2.userDisabled, false, "Addon 2 should now be enabled");
Expand Down Expand Up @@ -214,7 +288,10 @@ add_task(function* test_sideloading() {
checkNotification(panel, DEFAULT_ICON_URL, [["webextPerms.hostDescription.allUrls"]]);

// Accept the permissions
disablePromise = promiseSetDisabled(mock3);
panel.button.click();
value = yield disablePromise;
is(value, false, "userDisabled should be set on addon 3");

addon3 = yield AddonManager.getAddonByID(ID3);
is(addon3.userDisabled, false, "Addon 3 should be enabled");
Expand All @@ -239,7 +316,10 @@ add_task(function* test_sideloading() {
checkNotification(panel, DEFAULT_ICON_URL, [["webextPerms.hostDescription.allUrls"]]);

// Accept the permissions
disablePromise = promiseSetDisabled(mock4);
panel.button.click();
value = yield disablePromise;
is(value, false, "userDisabled should be set on addon 4");

addon4 = yield AddonManager.getAddonByID(ID4);
is(addon4.userDisabled, false, "Addon 4 should be enabled");
Expand All @@ -249,11 +329,5 @@ add_task(function* test_sideloading() {

isnot(menuButton.getAttribute("badge-status"), "addon-alert", "Should no longer have addon alert badge");

yield new Promise(resolve => setTimeout(resolve, 100));

for (let addon of [addon1, addon2, addon3, addon4]) {
addon.uninstall();
}

yield BrowserTestUtils.removeTab(gBrowser.selectedTab);
});
2 changes: 1 addition & 1 deletion browser/base/content/test/webextensions/head.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ function checkNotification(panel, checkIcon, permissions) {
let header = document.getElementById("addon-webext-perm-intro");

if (checkIcon instanceof RegExp) {
ok(checkIcon.test(icon), `Notification icon is correct ${JSON.stringify(icon)} ~= ${checkIcon}`);
ok(checkIcon.test(icon), "Notification icon is correct");
} else if (typeof checkIcon == "function") {
ok(checkIcon(icon), "Notification icon is correct");
} else {
Expand Down
Loading

0 comments on commit 6559420

Please sign in to comment.