Backed out 2 changesets (bug 1343583) at developer's request a=backout

Backed out changeset 10fccfc11db1 (bug 1343583)
Backed out changeset 3b9e06e3d9b8 (bug 1343583)

MozReview-Commit-ID: FKEYDU9MZIa
This commit is contained in:
Wes Kocher 2017-03-02 10:44:07 -08:00
parent 8ba3f9bd61
commit b9ff582762
9 changed files with 23 additions and 46 deletions

View File

@ -175,7 +175,7 @@ add_task(function* testTabSwitchContext() {
"2.png": imageBuffer,
},
getTests: function(tabs, expectDefaults) {
getTests(tabs, expectDefaults) {
const DEFAULT_BADGE_COLOR = [0xd9, 0, 0, 255];
let details = [
@ -331,7 +331,7 @@ add_task(function* testDefaultTitle() {
"icon.png": imageBuffer,
},
getTests: function(tabs, expectDefaults) {
getTests(tabs, expectDefaults) {
const DEFAULT_BADGE_COLOR = [0xd9, 0, 0, 255];
let details = [

View File

@ -53,7 +53,7 @@ add_task(function* testTabSwitchContext() {
"2.png": imageBuffer,
},
getTests: function(tabs) {
getTests(tabs) {
let details = [
{"icon": browser.runtime.getURL("default.png"),
"popup": browser.runtime.getURL("default.html"),

View File

@ -53,7 +53,7 @@ add_task(function* testTabSwitchContext() {
"2.png": imageBuffer,
},
getTests: function(tabs) {
getTests(tabs) {
let details = [
{"icon": browser.runtime.getURL("default.png"),
"popup": browser.runtime.getURL("default.html"),
@ -190,7 +190,7 @@ add_task(function* testDefaultTitle() {
"icon.png": imageBuffer,
},
getTests: function(tabs) {
getTests(tabs) {
let details = [
{"title": "Foo Extension",
"popup": "",

View File

@ -171,7 +171,7 @@ add_task(function* testTabSwitchContext() {
"2.png": imageBuffer,
},
getTests: function(tabs, expectDefaults) {
getTests(tabs, expectDefaults) {
let details = [
{"icon": browser.runtime.getURL("default.png"),
"panel": browser.runtime.getURL("default.html"),
@ -324,7 +324,7 @@ add_task(function* testDefaultTitle() {
"icon.png": imageBuffer,
},
getTests: function(tabs, expectDefaults) {
getTests(tabs, expectDefaults) {
let details = [
{"title": "Foo Extension",
"panel": browser.runtime.getURL("sidebar.html"),

View File

@ -90,7 +90,7 @@ add_task(function* testBadPermissions() {
},
},
},
contentSetup: function() {
contentSetup() {
browser.commands.onCommand.addListener(function(command) {
if (command == "test-tabs-executeScript") {
browser.test.sendMessage("tabs-command-key-pressed");
@ -132,7 +132,7 @@ add_task(function* testBadPermissions() {
"permissions": ["http://example.com/", "activeTab"],
"page_action": {},
},
contentSetup: async function() {
async contentSetup() {
let [tab] = await browser.tabs.query({active: true, currentWindow: true});
await browser.pageAction.show(tab.id);
},

View File

@ -86,7 +86,7 @@ add_task(function* testGoodPermissions() {
},
},
},
contentSetup: function() {
contentSetup() {
browser.commands.onCommand.addListener(function(command) {
if (command == "test-tabs-executeScript") {
browser.test.sendMessage("tabs-command-key-pressed");
@ -106,7 +106,7 @@ add_task(function* testGoodPermissions() {
"permissions": ["activeTab"],
"browser_action": {},
},
contentSetup: function() {
contentSetup() {
browser.browserAction.onClicked.addListener(() => {
browser.test.log("Clicked.");
});
@ -162,7 +162,7 @@ add_task(function* testGoodPermissions() {
manifest: {
"permissions": ["activeTab", "contextMenus"],
},
contentSetup: function() {
contentSetup() {
browser.contextMenus.create({title: "activeTab", contexts: ["all"]});
return Promise.resolve();
},

View File

@ -1,7 +1,5 @@
var ExtensionTestUtils = {};
const {ExtensionTestCommon} = SpecialPowers.Cu.import("resource://testing-common/ExtensionTestCommon.jsm", {});
ExtensionTestUtils.loadExtension = function(ext)
{
// Cleanup functions need to be registered differently depending on
@ -92,11 +90,14 @@ ExtensionTestUtils.loadExtension = function(ext)
if (ext.files) {
ext.files = Object.assign({}, ext.files);
for (let filename of Object.keys(ext.files)) {
ext.files[filename] = ExtensionTestCommon.serializeScript(ext.files[filename]);
let file = ext.files[filename];
if (typeof file == "function") {
ext.files[filename] = `(${file})();`
}
}
}
if ("background" in ext) {
ext.background = ExtensionTestCommon.serializeScript(ext.background);
if (typeof ext.background == "function") {
ext.background = `(${ext.background})();`
}
var extension = SpecialPowers.loadExtension(ext, handler);

View File

@ -140,7 +140,7 @@ class MockExtension {
}
}
this.ExtensionTestCommon = class ExtensionTestCommon {
class ExtensionTestCommon {
/**
* This code is designed to make it easy to test a WebExtension
* without creating a bunch of files. Everything is contained in a
@ -283,7 +283,7 @@ this.ExtensionTestCommon = class ExtensionTestCommon {
for (let filename in files) {
let script = files[filename];
if (typeof(script) == "function") {
script = this.serializeScript(script);
script = "(" + script.toString() + ")()";
} else if (instanceOf(script, "Object") || instanceOf(script, "Array")) {
script = JSON.stringify(script);
}
@ -304,30 +304,6 @@ this.ExtensionTestCommon = class ExtensionTestCommon {
return file;
}
/**
* Properly serialize a script into eval-able code string.
*
* @param {string|function|Array} script
* @returns {string}
*/
static serializeScript(script) {
if (Array.isArray(script)) {
return script.map(this.serializeScript).join(";");
}
if (typeof script !== "function") {
return script;
}
// Serialization of object methods doesn't include `function` anymore.
const method = /^(async )?(\w+)\(/;
let code = script.toString();
let match = code.match(method);
if (match && match[2] !== "function") {
code = code.replace(method, "$1function $2(");
}
return `(${code})();`;
}
/**
* Generates a new extension using |Extension.generateXPI|, and initializes a
* new |Extension| instance which will execute it.
@ -367,4 +343,4 @@ this.ExtensionTestCommon = class ExtensionTestCommon {
cleanupFile: file,
});
}
};
}

View File

@ -40,7 +40,7 @@ add_task(function* test_background_clipboard_permissions() {
browser.test.sendMessage("ready");
}
let extensionData = {
background: [shared, backgroundScript],
background: `(${shared})();(${backgroundScript})();`,
};
let extension = ExtensionTestUtils.loadExtension(extensionData);
yield extension.startup();
@ -194,7 +194,7 @@ add_task(function* test_background_clipboard_paste() {
manifest: {
permissions: ["clipboardRead"],
},
background: [shared, background],
background: `(${shared})();(${background})();`,
});
const STRANGE = "Stranger Things";