mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backed out 11 changesets (bug 1201377, bug 1199800, bug 1197437, bug 1199832, bug 1199698, bug 1199842) for breaking browser_ext_tabs_executeScript.js test on a CLOSED TREE
Backed out changeset 8d8d73d3c3e1 (bug 1201377) Backed out changeset 4ed8951e3f54 (bug 1199842) Backed out changeset 5830178bc008 (bug 1199832) Backed out changeset 4445c570fe49 (bug 1199698) Backed out changeset 35fc1e25d167 (bug 1199800) Backed out changeset 54c4c3bd2454 (bug 1199800) Backed out changeset bd3112ce6b9b (bug 1199800) Backed out changeset 701e56e18ca7 (bug 1199800) Backed out changeset 4407d50a7995 (bug 1199800) Backed out changeset af2fbe345712 (bug 1199800) Backed out changeset 0a41d20fcf77 (bug 1197437)
This commit is contained in:
parent
d16d7cf5cd
commit
c8fb1255f1
@ -140,7 +140,6 @@ BrowserAction.prototype = {
|
||||
panel.setAttribute("flip", "slide");
|
||||
node.appendChild(panel);
|
||||
|
||||
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
||||
let browser = document.createElementNS(XUL_NS, "browser");
|
||||
browser.setAttribute("type", "content");
|
||||
browser.setAttribute("disableglobalhistory", "true");
|
||||
|
@ -5,5 +5,3 @@
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
JAR_MANIFESTS += ['jar.mn']
|
||||
|
||||
BROWSER_CHROME_MANIFESTS += ['test/browser/browser.ini']
|
||||
|
@ -1,5 +0,0 @@
|
||||
[browser_extensions_simple.js]
|
||||
[browser_ext_browserAction_simple.js]
|
||||
[browser_ext_tabs_executeScript.js]
|
||||
[browser_ext_tabs_query.js]
|
||||
[browser_ext_tabs_update.js]
|
@ -1,36 +0,0 @@
|
||||
add_task(function* () {
|
||||
let extension = ExtensionTestUtils.loadExtension({
|
||||
manifest: {
|
||||
"browser_action": {
|
||||
"default_popup": "popup.html"
|
||||
}
|
||||
},
|
||||
|
||||
files: {
|
||||
"popup.html": `
|
||||
<!DOCTYPE html>
|
||||
<html><body>
|
||||
<script src="popup.js"></script>
|
||||
</body></html>
|
||||
`,
|
||||
|
||||
"popup.js": function() {
|
||||
browser.runtime.sendMessage("from-popup");
|
||||
}
|
||||
},
|
||||
|
||||
background: function() {
|
||||
browser.runtime.onMessage.addListener(msg => {
|
||||
browser.test.assertEq(msg, "from-popup", "correct message received");
|
||||
browser.test.notifyPass("browser_action.simple");
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
yield extension.startup();
|
||||
|
||||
// FIXME: Should really test opening the popup here.
|
||||
|
||||
yield extension.awaitFinish("browser_action.simple");
|
||||
yield extension.unload();
|
||||
});
|
@ -1,32 +0,0 @@
|
||||
add_task(function* () {
|
||||
let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "http://mochi.test:8888/");
|
||||
|
||||
let extension = ExtensionTestUtils.loadExtension({
|
||||
manifest: {
|
||||
"permissions": ["tabs"]
|
||||
},
|
||||
|
||||
background: function() {
|
||||
browser.runtime.onMessage.addListener((msg, sender) => {
|
||||
browser.test.assertEq(msg, "script ran", "script ran");
|
||||
browser.test.notifyPass("executeScript");
|
||||
});
|
||||
|
||||
browser.tabs.executeScript({
|
||||
file: "script.js"
|
||||
});
|
||||
},
|
||||
|
||||
files: {
|
||||
"script.js": function() {
|
||||
browser.runtime.sendMessage("script ran");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
yield extension.startup();
|
||||
yield extension.awaitFinish("executeScript");
|
||||
yield extension.unload();
|
||||
|
||||
yield BrowserTestUtils.removeTab(tab);
|
||||
});
|
@ -1,48 +0,0 @@
|
||||
add_task(function* () {
|
||||
let tab1 = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "about:robots");
|
||||
let tab2 = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "about:config");
|
||||
|
||||
gBrowser.selectedTab = tab1;
|
||||
|
||||
let extension = ExtensionTestUtils.loadExtension({
|
||||
manifest: {
|
||||
"permissions": ["tabs"]
|
||||
},
|
||||
|
||||
background: function() {
|
||||
browser.tabs.query({
|
||||
lastFocusedWindow: true
|
||||
}, function(tabs) {
|
||||
browser.test.assertEq(tabs.length, 3, "should have three tabs");
|
||||
|
||||
tabs.sort(function (tab1, tab2) { return tab1.index - tab2.index; });
|
||||
|
||||
browser.test.assertEq(tabs[0].url, "about:blank", "first tab blank");
|
||||
tabs.shift();
|
||||
|
||||
browser.test.assertTrue(tabs[0].active, "tab 0 active");
|
||||
browser.test.assertFalse(tabs[1].active, "tab 1 inactive");
|
||||
|
||||
browser.test.assertFalse(tabs[0].pinned, "tab 0 unpinned");
|
||||
browser.test.assertFalse(tabs[1].pinned, "tab 1 unpinned");
|
||||
|
||||
browser.test.assertEq(tabs[0].url, "about:robots", "tab 0 url correct");
|
||||
browser.test.assertEq(tabs[1].url, "about:config", "tab 1 url correct");
|
||||
|
||||
browser.test.assertEq(tabs[0].status, "complete", "tab 0 status correct");
|
||||
browser.test.assertEq(tabs[1].status, "complete", "tab 1 status correct");
|
||||
|
||||
browser.test.assertEq(tabs[0].title, "Gort! Klaatu barada nikto!", "tab 0 title correct");
|
||||
|
||||
browser.test.notifyPass("tabs.query");
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
yield extension.startup();
|
||||
yield extension.awaitFinish("tabs.query");
|
||||
yield extension.unload();
|
||||
|
||||
yield BrowserTestUtils.removeTab(tab1);
|
||||
yield BrowserTestUtils.removeTab(tab2);
|
||||
});
|
@ -1,42 +0,0 @@
|
||||
add_task(function* () {
|
||||
let tab1 = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "about:robots");
|
||||
let tab2 = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "about:config");
|
||||
|
||||
gBrowser.selectedTab = tab1;
|
||||
|
||||
let extension = ExtensionTestUtils.loadExtension({
|
||||
manifest: {
|
||||
"permissions": ["tabs"]
|
||||
},
|
||||
|
||||
background: function() {
|
||||
browser.tabs.query({
|
||||
lastFocusedWindow: true,
|
||||
}, function(tabs) {
|
||||
browser.test.assertEq(tabs.length, 3, "should have three tabs");
|
||||
|
||||
tabs.sort(function (tab1, tab2) { return tab1.index - tab2.index; });
|
||||
|
||||
browser.test.assertEq(tabs[0].url, "about:blank", "first tab blank");
|
||||
tabs.shift();
|
||||
|
||||
browser.test.assertTrue(tabs[0].active, "tab 0 active");
|
||||
browser.test.assertFalse(tabs[1].active, "tab 1 inactive");
|
||||
|
||||
browser.tabs.update(tabs[1].id, {active: true}, function() {
|
||||
browser.test.sendMessage("check");
|
||||
});
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
yield extension.startup();
|
||||
yield extension.awaitMessage("check");
|
||||
|
||||
ok(gBrowser.selectedTab == tab2, "correct tab selected");
|
||||
|
||||
yield extension.unload();
|
||||
|
||||
yield BrowserTestUtils.removeTab(tab1);
|
||||
yield BrowserTestUtils.removeTab(tab2);
|
||||
});
|
@ -1,22 +0,0 @@
|
||||
add_task(function* test_simple() {
|
||||
let extension = ExtensionTestUtils.loadExtension("simple");
|
||||
info("load complete");
|
||||
yield extension.startup();
|
||||
info("startup complete");
|
||||
yield extension.unload();
|
||||
info("extension unloaded successfully");
|
||||
});
|
||||
|
||||
add_task(function* test_background() {
|
||||
let extension = ExtensionTestUtils.loadExtension("background");
|
||||
info("load complete");
|
||||
yield extension.startup();
|
||||
let x = yield extension.awaitMessage("running");
|
||||
is(x, 1, "got correct value from extension");
|
||||
info("startup complete");
|
||||
extension.sendMessage(10, 20);
|
||||
yield extension.awaitFinish();
|
||||
info("test complete");
|
||||
yield extension.unload();
|
||||
info("extension unloaded successfully");
|
||||
});
|
@ -159,11 +159,6 @@ function Tester(aTests, aDumper, aCallback) {
|
||||
this._scriptLoader.loadSubScript("chrome://mochikit/content/chrome-harness.js", simpleTestScope);
|
||||
this.SimpleTest = simpleTestScope.SimpleTest;
|
||||
|
||||
var extensionUtilsScope = {};
|
||||
extensionUtilsScope.SimpleTest = this.SimpleTest;
|
||||
this._scriptLoader.loadSubScript("chrome://mochikit/content/tests/SimpleTest/ExtensionTestUtils.js", extensionUtilsScope);
|
||||
this.ExtensionTestUtils = extensionUtilsScope.ExtensionTestUtils;
|
||||
|
||||
this.SimpleTest.harnessParameters = gConfig;
|
||||
|
||||
this.MemoryStats = simpleTestScope.MemoryStats;
|
||||
@ -216,7 +211,6 @@ Tester.prototype = {
|
||||
SimpleTest: {},
|
||||
Task: null,
|
||||
ContentTask: null,
|
||||
ExtensionTestUtils: null,
|
||||
Assert: null,
|
||||
|
||||
repeat: 0,
|
||||
@ -692,7 +686,6 @@ Tester.prototype = {
|
||||
this.currentTest.scope.ContentTask = this.ContentTask;
|
||||
this.currentTest.scope.BrowserTestUtils = this.BrowserTestUtils;
|
||||
this.currentTest.scope.TestUtils = this.TestUtils;
|
||||
this.currentTest.scope.ExtensionTestUtils = this.ExtensionTestUtils;
|
||||
// Pass a custom report function for mochitest style reporting.
|
||||
this.currentTest.scope.Assert = new this.Assert(function(err, message, stack) {
|
||||
let res;
|
||||
@ -1089,7 +1082,6 @@ testScope.prototype = {
|
||||
ContentTask: null,
|
||||
BrowserTestUtils: null,
|
||||
TestUtils: null,
|
||||
ExtensionTestUtils: null,
|
||||
Assert: null,
|
||||
|
||||
/**
|
||||
|
@ -22,7 +22,6 @@ mochikit.jar:
|
||||
content/static/harness.css (static/harness.css)
|
||||
content/tests/SimpleTest/ChromePowers.js (tests/SimpleTest/ChromePowers.js)
|
||||
content/tests/SimpleTest/EventUtils.js (tests/SimpleTest/EventUtils.js)
|
||||
content/tests/SimpleTest/ExtensionTestUtils.js (tests/SimpleTest/ExtensionTestUtils.js)
|
||||
content/tests/SimpleTest/SpawnTask.js (tests/SimpleTest/SpawnTask.js)
|
||||
content/tests/SimpleTest/AsyncUtilsContent.js (tests/SimpleTest/AsyncUtilsContent.js)
|
||||
content/tests/SimpleTest/ChromeUtils.js (tests/SimpleTest/ChromeUtils.js)
|
||||
|
@ -15,8 +15,6 @@ function ChromePowers(window) {
|
||||
}
|
||||
|
||||
this.spObserver = new SpecialPowersObserverAPI();
|
||||
this.spObserver._sendReply = this._sendReply.bind(this);
|
||||
this.listeners = new Map();
|
||||
}
|
||||
|
||||
ChromePowers.prototype = new SpecialPowersAPI();
|
||||
@ -27,32 +25,14 @@ ChromePowers.prototype.sanityCheck = function() { return "foo"; };
|
||||
// This gets filled in in the constructor.
|
||||
ChromePowers.prototype.DOMWindowUtils = undefined;
|
||||
|
||||
ChromePowers.prototype._sendReply = function(aOrigMsg, aType, aMsg) {
|
||||
var msg = {'name':aType, 'json': aMsg, 'data': aMsg};
|
||||
if (!this.listeners.has(aType)) {
|
||||
throw new Error(`No listener for ${aType}`);
|
||||
}
|
||||
this.listeners.get(aType)(msg);
|
||||
ChromePowers.prototype._sendSyncMessage = function(type, msg) {
|
||||
var aMessage = {'name':type, 'json': msg};
|
||||
return [this._receiveMessage(aMessage)];
|
||||
};
|
||||
|
||||
ChromePowers.prototype._sendSyncMessage = function(aType, aMsg) {
|
||||
var msg = {'name':aType, 'json': aMsg, 'data': aMsg};
|
||||
return [this._receiveMessage(msg)];
|
||||
};
|
||||
|
||||
ChromePowers.prototype._sendAsyncMessage = function(aType, aMsg) {
|
||||
var msg = {'name':aType, 'json': aMsg, 'data': aMsg};
|
||||
this._receiveMessage(msg);
|
||||
};
|
||||
|
||||
ChromePowers.prototype._addMessageListener = function(aType, aCallback) {
|
||||
if (this.listeners.has(aType)) {
|
||||
throw new Error(`unable to handle multiple listeners for ${aType}`);
|
||||
}
|
||||
this.listeners.set(aType, aCallback);
|
||||
};
|
||||
ChromePowers.prototype._removeMessageListener = function(aType, aCallback) {
|
||||
this.listeners.delete(aType);
|
||||
ChromePowers.prototype._sendAsyncMessage = function(type, msg) {
|
||||
var aMessage = {'name':type, 'json': msg};
|
||||
this._receiveMessage(aMessage);
|
||||
};
|
||||
|
||||
ChromePowers.prototype.registerProcessCrashObservers = function() {
|
||||
|
@ -1,73 +0,0 @@
|
||||
var ExtensionTestUtils = {};
|
||||
|
||||
ExtensionTestUtils.loadExtension = function(ext)
|
||||
{
|
||||
var testResolve;
|
||||
var testDone = new Promise(resolve => { testResolve = resolve; });
|
||||
|
||||
var messageHandler = new Map();
|
||||
|
||||
function testHandler(kind, pass, msg, ...args) {
|
||||
if (kind == "test-eq") {
|
||||
var [expected, actual] = args;
|
||||
SimpleTest.ok(pass, `${msg} - Expected: ${expected}, Actual: ${actual}`);
|
||||
} else if (kind == "test-log") {
|
||||
SimpleTest.info(msg);
|
||||
} else if (kind == "test-result") {
|
||||
SimpleTest.ok(pass, msg);
|
||||
}
|
||||
}
|
||||
|
||||
var handler = {
|
||||
testResult(kind, pass, msg, ...args) {
|
||||
if (kind == "test-done") {
|
||||
SimpleTest.ok(pass, msg);
|
||||
return testResolve(msg);
|
||||
}
|
||||
testHandler(kind, pass, msg, ...args);
|
||||
},
|
||||
|
||||
testMessage(msg, ...args) {
|
||||
var handler = messageHandler.get(msg);
|
||||
if (!handler) {
|
||||
return;
|
||||
}
|
||||
|
||||
handler(...args);
|
||||
},
|
||||
};
|
||||
|
||||
var extension = SpecialPowers.loadExtension(ext, handler);
|
||||
|
||||
extension.awaitMessage = (msg) => {
|
||||
return new Promise(resolve => {
|
||||
if (messageHandler.has(msg)) {
|
||||
throw new Error("only one message handler allowed");
|
||||
}
|
||||
|
||||
messageHandler.set(msg, (...args) => {
|
||||
messageHandler.delete(msg);
|
||||
resolve(...args);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
extension.onMessage = (msg, callback) => {
|
||||
if (messageHandler.has(msg)) {
|
||||
throw new Error("only one message handler allowed");
|
||||
}
|
||||
messageHandler.set(msg, callback);
|
||||
};
|
||||
|
||||
extension.awaitFinish = (msg) => {
|
||||
return testDone.then(actual => {
|
||||
if (msg) {
|
||||
SimpleTest.is(actual, msg, "test result correct");
|
||||
}
|
||||
return actual;
|
||||
});
|
||||
};
|
||||
|
||||
SimpleTest.info(`Extension loaded`);
|
||||
return extension;
|
||||
}
|
@ -9,7 +9,6 @@ TEST_HARNESS_FILES.testing.mochitest.tests.SimpleTest += [
|
||||
'/testing/specialpowers/content/MozillaLogger.js',
|
||||
'ChromeUtils.js',
|
||||
'EventUtils.js',
|
||||
'ExtensionTestUtils.js',
|
||||
'iframe-between-tests.html',
|
||||
'LogController.js',
|
||||
'MemoryStats.js',
|
||||
|
@ -560,21 +560,11 @@ SpecialPowersObserverAPI.prototype = {
|
||||
let {Extension} = Components.utils.import("resource://gre/modules/Extension.jsm", {});
|
||||
|
||||
let id = aMessage.data.id;
|
||||
let ext = aMessage.data.ext;
|
||||
let extension;
|
||||
if (typeof(ext) == "string") {
|
||||
let target = "resource://testing-common/extensions/" + ext + "/";
|
||||
let resourceHandler = Services.io.getProtocolHandler("resource")
|
||||
.QueryInterface(Ci.nsISubstitutingProtocolHandler);
|
||||
let resURI = Services.io.newURI(target, null, null);
|
||||
let uri = Services.io.newURI(resourceHandler.resolveURI(resURI), null, null);
|
||||
extension = new Extension({
|
||||
id,
|
||||
resourceURI: uri
|
||||
});
|
||||
} else {
|
||||
extension = Extension.generate(ext);
|
||||
}
|
||||
let uri = Services.io.newURI(aMessage.data.url, null, null);
|
||||
let extension = new Extension({
|
||||
id,
|
||||
resourceURI: uri
|
||||
});
|
||||
|
||||
let resultListener = (...args) => {
|
||||
this._sendReply(aMessage, "SPExtensionMessage", {id, type: "testResult", args});
|
||||
|
@ -2044,7 +2044,7 @@ SpecialPowersAPI.prototype = {
|
||||
this.notifyObserversInParentProcess(null, "browser:purge-domain-data", "example.com");
|
||||
},
|
||||
|
||||
loadExtension: function(ext, handler) {
|
||||
loadExtension: function(url, handler) {
|
||||
let uuidGenerator = Cc["@mozilla.org/uuid-generator;1"].getService(Ci.nsIUUIDGenerator);
|
||||
let id = uuidGenerator.generateUUID().number;
|
||||
|
||||
@ -2055,11 +2055,13 @@ SpecialPowersAPI.prototype = {
|
||||
});
|
||||
let unloadPromise = new Promise(resolve => { resolveUnload = resolve; });
|
||||
|
||||
handler = Cu.waiveXrays(handler);
|
||||
ext = Cu.waiveXrays(ext);
|
||||
handler = handler.wrappedJSObject;
|
||||
|
||||
let sp = this;
|
||||
let extension = {
|
||||
id,
|
||||
url,
|
||||
|
||||
startup() {
|
||||
sp._sendAsyncMessage("SPStartupExtension", {id});
|
||||
return startupPromise;
|
||||
@ -2075,13 +2077,13 @@ SpecialPowersAPI.prototype = {
|
||||
},
|
||||
};
|
||||
|
||||
this._sendAsyncMessage("SPLoadExtension", {ext, id});
|
||||
this._sendAsyncMessage("SPLoadExtension", {url, id});
|
||||
|
||||
let listener = (msg) => {
|
||||
if (msg.data.id == id) {
|
||||
if (msg.data.type == "extensionStarted") {
|
||||
resolveStartup();
|
||||
} else if (msg.data.type == "extensionFailed") {
|
||||
} if (msg.data.type == "extensionFailed") {
|
||||
rejectStartup("startup failed");
|
||||
} else if (msg.data.type == "extensionUnloaded") {
|
||||
this._removeMessageListener("SPExtensionMessage", listener);
|
||||
|
@ -29,8 +29,6 @@ XPCOMUtils.defineLazyModuleGetter(this, "MatchPattern",
|
||||
"resource://gre/modules/MatchPattern.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "NetUtil",
|
||||
"resource://gre/modules/NetUtil.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "FileUtils",
|
||||
"resource://gre/modules/FileUtils.jsm");
|
||||
|
||||
Cu.import("resource://gre/modules/ExtensionManagement.jsm");
|
||||
|
||||
@ -53,7 +51,6 @@ let {
|
||||
MessageBroker,
|
||||
Messenger,
|
||||
injectAPI,
|
||||
flushJarCache,
|
||||
} = ExtensionUtils;
|
||||
|
||||
let scriptScope = this;
|
||||
@ -319,12 +316,6 @@ this.Extension = function(addonData)
|
||||
uuid = uuid.substring(1, uuid.length - 1); // Strip of { and } off the UUID.
|
||||
this.uuid = uuid;
|
||||
|
||||
if (addonData.cleanupFile) {
|
||||
Services.obs.addObserver(this, "xpcom-shutdown", false);
|
||||
this.cleanupFile = addonData.cleanupFile || null;
|
||||
delete addonData.cleanupFile;
|
||||
}
|
||||
|
||||
this.addonData = addonData;
|
||||
this.id = addonData.id;
|
||||
this.baseURI = Services.io.newURI("moz-extension://" + uuid, null, null);
|
||||
@ -345,125 +336,6 @@ this.Extension = function(addonData)
|
||||
this.emitter = new EventEmitter();
|
||||
}
|
||||
|
||||
/**
|
||||
* This code is designed to make it easy to test a WebExtension
|
||||
* without creating a bunch of files. Everything is contained in a
|
||||
* single JSON blob.
|
||||
*
|
||||
* Properties:
|
||||
* "background": "<JS code>"
|
||||
* A script to be loaded as the background script.
|
||||
* The "background" section of the "manifest" property is overwritten
|
||||
* if this is provided.
|
||||
* "manifest": {...}
|
||||
* Contents of manifest.json
|
||||
* "files": {"filename1": "contents1", ...}
|
||||
* Data to be included as files. Can be referenced from the manifest.
|
||||
* If a manifest file is provided here, it takes precedence over
|
||||
* a generated one. Always use "/" as a directory separator.
|
||||
* Directories should appear here only implicitly (as a prefix
|
||||
* to file names)
|
||||
*
|
||||
* To make things easier, the value of "background" and "files"[] can
|
||||
* be a function, which is converted to source that is run.
|
||||
*/
|
||||
this.Extension.generate = function(data)
|
||||
{
|
||||
let manifest = data.manifest;
|
||||
if (!manifest) {
|
||||
manifest = {};
|
||||
}
|
||||
|
||||
let files = data.files;
|
||||
if (!files) {
|
||||
files = {};
|
||||
}
|
||||
|
||||
function provide(obj, keys, value, override = false) {
|
||||
if (keys.length == 1) {
|
||||
if (!(keys[0] in obj) || override) {
|
||||
obj[keys[0]] = value;
|
||||
}
|
||||
} else {
|
||||
if (!(keys[0] in obj)) {
|
||||
obj[keys[0]] = {};
|
||||
}
|
||||
provide(obj[keys[0]], keys.slice(1), value, override);
|
||||
}
|
||||
}
|
||||
|
||||
let uuidGenerator = Cc["@mozilla.org/uuid-generator;1"].getService(Ci.nsIUUIDGenerator);
|
||||
let uuid = uuidGenerator.generateUUID().number;
|
||||
provide(manifest, ["applications", "gecko", "id"], uuid);
|
||||
|
||||
provide(manifest, ["name"], "Generated extension");
|
||||
provide(manifest, ["manifest_version"], 2);
|
||||
provide(manifest, ["version"], "1.0");
|
||||
|
||||
if (data.background) {
|
||||
let uuidGenerator = Cc["@mozilla.org/uuid-generator;1"].getService(Ci.nsIUUIDGenerator);
|
||||
let bgScript = uuidGenerator.generateUUID().number + ".js";
|
||||
|
||||
provide(manifest, ["background", "scripts"], [bgScript], true);
|
||||
files[bgScript] = data.background;
|
||||
}
|
||||
|
||||
provide(files, ["manifest.json"], JSON.stringify(manifest));
|
||||
|
||||
let ZipWriter = Components.Constructor("@mozilla.org/zipwriter;1", "nsIZipWriter");
|
||||
let zipW = new ZipWriter();
|
||||
|
||||
let file = FileUtils.getFile("TmpD", ["generated-extension.xpi"]);
|
||||
file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, FileUtils.PERMS_FILE);
|
||||
|
||||
const MODE_WRONLY = 0x02;
|
||||
const MODE_TRUNCATE = 0x20;
|
||||
zipW.open(file, MODE_WRONLY | MODE_TRUNCATE);
|
||||
|
||||
// Needs to be in microseconds for some reason.
|
||||
let time = Date.now() * 1000;
|
||||
|
||||
function generateFile(filename) {
|
||||
let components = filename.split("/");
|
||||
let path = "";
|
||||
for (let component of components.slice(0, -1)) {
|
||||
path += component;
|
||||
if (!zipW.hasEntry(path)) {
|
||||
zipW.addEntryDirectory(path, time, false);
|
||||
}
|
||||
|
||||
path += "/";
|
||||
}
|
||||
}
|
||||
|
||||
for (let filename in files) {
|
||||
let script = files[filename];
|
||||
if (typeof(script) == "function") {
|
||||
script = "(" + script.toString() + ")()";
|
||||
}
|
||||
|
||||
let stream = Cc["@mozilla.org/io/string-input-stream;1"].createInstance(Ci.nsIStringInputStream);
|
||||
stream.data = script;
|
||||
|
||||
generateFile(filename);
|
||||
zipW.addEntryStream(filename, time, 0, stream, false);
|
||||
}
|
||||
|
||||
zipW.close();
|
||||
|
||||
flushJarCache(file);
|
||||
Services.ppmm.broadcastAsyncMessage("Extension:FlushJarCache", {path: file.path});
|
||||
|
||||
let fileURI = Services.io.newFileURI(file);
|
||||
let jarURI = Services.io.newURI("jar:" + fileURI.spec + "!/", null, null);
|
||||
|
||||
return new Extension({
|
||||
id: uuid,
|
||||
resourceURI: jarURI,
|
||||
cleanupFile: file
|
||||
});
|
||||
}
|
||||
|
||||
Extension.prototype = {
|
||||
on(hook, f) {
|
||||
return this.emitter.on(hook, f);
|
||||
@ -706,31 +578,6 @@ Extension.prototype = {
|
||||
});
|
||||
},
|
||||
|
||||
cleanupGeneratedFile() {
|
||||
if (!this.cleanupFile) {
|
||||
return;
|
||||
}
|
||||
|
||||
let file = this.cleanupFile;
|
||||
this.cleanupFile = null;
|
||||
|
||||
Services.obs.removeObserver(this, "xpcom-shutdown");
|
||||
|
||||
let count = Services.ppmm.childCount;
|
||||
|
||||
Services.ppmm.addMessageListener("Extension:FlushJarCacheComplete", function listener() {
|
||||
count--;
|
||||
if (count == 0) {
|
||||
// We can't delete this file until everyone using it has
|
||||
// closed it (because Windows is dumb). So we wait for all the
|
||||
// child processes (including the parent) to flush their JAR
|
||||
// caches. These caches may keep the file open.
|
||||
file.remove(false);
|
||||
}
|
||||
});
|
||||
Services.ppmm.broadcastAsyncMessage("Extension:FlushJarCache", {path: file.path});
|
||||
},
|
||||
|
||||
shutdown() {
|
||||
this.hasShutdown = true;
|
||||
if (!this.manifest) {
|
||||
@ -752,15 +599,6 @@ Extension.prototype = {
|
||||
Services.ppmm.broadcastAsyncMessage("Extension:Shutdown", {id: this.id});
|
||||
|
||||
ExtensionManagement.shutdownExtension(this.uuid);
|
||||
|
||||
// Clean up a generated file.
|
||||
this.cleanupGeneratedFile();
|
||||
},
|
||||
|
||||
observe(subject, topic, data) {
|
||||
if (topic == "xpcom-shutdown") {
|
||||
this.cleanupGeneratedFile();
|
||||
}
|
||||
},
|
||||
|
||||
hasPermission(perm) {
|
||||
|
@ -35,7 +35,6 @@ let {
|
||||
Messenger,
|
||||
ignoreEvent,
|
||||
injectAPI,
|
||||
flushJarCache,
|
||||
} = ExtensionUtils;
|
||||
|
||||
function isWhenBeforeOrSame(when1, when2)
|
||||
@ -223,10 +222,7 @@ function ExtensionContext(extensionId, contentWindow)
|
||||
{id: extensionId, frameId}, delegate);
|
||||
|
||||
let chromeObj = Cu.createObjectIn(this.sandbox, {defineAs: "browser"});
|
||||
|
||||
// Sandboxes don't get Xrays for some weird compatibility
|
||||
// reason. However, we waive here anyway in case that changes.
|
||||
Cu.waiveXrays(this.sandbox).chrome = Cu.waiveXrays(this.sandbox).browser;
|
||||
this.sandbox.wrappedJSObject.chrome = this.sandbox.wrappedJSObject.browser;
|
||||
injectAPI(api(this), chromeObj);
|
||||
|
||||
this.onClose = new Set();
|
||||
@ -243,6 +239,7 @@ ExtensionContext.prototype = {
|
||||
|
||||
callOnClose(obj) {
|
||||
this.onClose.add(obj);
|
||||
Cu.nukeSandbox(this.sandbox);
|
||||
},
|
||||
|
||||
forgetOnClose(obj) {
|
||||
@ -253,7 +250,6 @@ ExtensionContext.prototype = {
|
||||
for (let obj of this.onClose) {
|
||||
obj.close();
|
||||
}
|
||||
Cu.nukeSandbox(this.sandbox);
|
||||
},
|
||||
};
|
||||
|
||||
@ -336,17 +332,18 @@ let DocumentManager = {
|
||||
|
||||
executeScript(global, extensionId, script) {
|
||||
let window = global.content;
|
||||
let context = this.getContext(extensionId, window);
|
||||
let extensions = this.windows.get(window);
|
||||
if (!extensions) {
|
||||
return;
|
||||
}
|
||||
let context = extensions.get(extensionId);
|
||||
if (!context) {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: Somehow make sure we have the right permissions for this origin!
|
||||
|
||||
// FIXME: Script should be executed only if current state has
|
||||
// already reached its run_at state, or we have to keep it around
|
||||
// somewhere to execute later.
|
||||
context.execute(script, scheduled => true);
|
||||
// FIXME: Need to keep this around so that I will execute it later if we're not in the right state.
|
||||
context.execute(script, scheduled => scheduled == state);
|
||||
},
|
||||
|
||||
enumerateWindows: function*(docShell) {
|
||||
@ -418,7 +415,7 @@ let DocumentManager = {
|
||||
for (let script of extension.scripts) {
|
||||
if (script.matches(window)) {
|
||||
let context = this.getContext(extensionId, window);
|
||||
context.execute(script, scheduled => scheduled == state);
|
||||
context.execute(script, scheduled => isWhenBeforeOrSame(scheduled, state));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -461,7 +458,6 @@ let ExtensionManager = {
|
||||
init() {
|
||||
Services.cpmm.addMessageListener("Extension:Startup", this);
|
||||
Services.cpmm.addMessageListener("Extension:Shutdown", this);
|
||||
Services.cpmm.addMessageListener("Extension:FlushJarCache", this);
|
||||
|
||||
if (Services.cpmm.initialProcessData && "Extension:Extensions" in Services.cpmm.initialProcessData) {
|
||||
let extensions = Services.cpmm.initialProcessData["Extension:Extensions"];
|
||||
@ -479,29 +475,18 @@ let ExtensionManager = {
|
||||
receiveMessage({name, data}) {
|
||||
let extension;
|
||||
switch (name) {
|
||||
case "Extension:Startup": {
|
||||
extension = new BrowserExtensionContent(data);
|
||||
this.extensions.set(data.id, extension);
|
||||
DocumentManager.startupExtension(data.id);
|
||||
break;
|
||||
}
|
||||
case "Extension:Startup":
|
||||
extension = new BrowserExtensionContent(data);
|
||||
this.extensions.set(data.id, extension);
|
||||
DocumentManager.startupExtension(data.id);
|
||||
break;
|
||||
|
||||
case "Extension:Shutdown": {
|
||||
extension = this.extensions.get(data.id);
|
||||
extension.shutdown();
|
||||
DocumentManager.shutdownExtension(data.id);
|
||||
this.extensions.delete(data.id);
|
||||
break;
|
||||
}
|
||||
|
||||
case "Extension:FlushJarCache": {
|
||||
let nsIFile = Components.Constructor("@mozilla.org/file/local;1", "nsIFile",
|
||||
"initWithPath");
|
||||
let file = new nsIFile(data.path);
|
||||
flushJarCache(file);
|
||||
Services.cpmm.sendAsyncMessage("Extension:FlushJarCacheComplete");
|
||||
break;
|
||||
}
|
||||
case "Extension:Shutdown":
|
||||
extension = this.extensions.get(data.id);
|
||||
extension.shutdown();
|
||||
DocumentManager.shutdownExtension(data.id);
|
||||
this.extensions.delete(data.id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -527,11 +527,6 @@ Messenger.prototype = {
|
||||
},
|
||||
};
|
||||
|
||||
function flushJarCache(jarFile)
|
||||
{
|
||||
Services.obs.notifyObservers(jarFile, "flush-cache-entry", null);
|
||||
}
|
||||
|
||||
this.ExtensionUtils = {
|
||||
runSafeWithoutClone,
|
||||
runSafe,
|
||||
@ -542,6 +537,5 @@ this.ExtensionUtils = {
|
||||
injectAPI,
|
||||
MessageBroker,
|
||||
Messenger,
|
||||
flushJarCache,
|
||||
};
|
||||
|
||||
|
@ -1,10 +0,0 @@
|
||||
browser.runtime.onMessage.addListener(([msg, expectedState, readyState], sender) => {
|
||||
if (msg == "chrome-namespace-ok") {
|
||||
browser.test.sendMessage(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
browser.test.assertEq(msg, "script-run", "message type is correct");
|
||||
browser.test.assertEq(readyState, expectedState, "readyState is correct");
|
||||
browser.test.sendMessage("script-run-" + expectedState);
|
||||
});
|
@ -1 +0,0 @@
|
||||
chrome.runtime.sendMessage(["chrome-namespace-ok"]);
|
@ -1 +0,0 @@
|
||||
browser.runtime.sendMessage(["script-run", "interactive", document.readyState]);
|
@ -1 +0,0 @@
|
||||
browser.runtime.sendMessage(["script-run", "complete", document.readyState]);
|
@ -1 +0,0 @@
|
||||
browser.runtime.sendMessage(["script-run", "loading", document.readyState]);
|
@ -1,33 +0,0 @@
|
||||
{
|
||||
"name": "Content script extension test",
|
||||
"version": "1.0",
|
||||
"manifest_version": 2,
|
||||
"description": "",
|
||||
|
||||
"content_scripts": [
|
||||
{
|
||||
"matches": ["http://mochi.test/tests/toolkit/components/extensions/test/mochitest/file_contentscript_*.html"],
|
||||
"js": ["content_script_start.js"],
|
||||
"run_at": "document_start"
|
||||
},
|
||||
{
|
||||
"matches": ["http://mochi.test/tests/toolkit/components/extensions/test/mochitest/file_contentscript_*.html"],
|
||||
"js": ["content_script_end.js"],
|
||||
"run_at": "document_end"
|
||||
},
|
||||
{
|
||||
"matches": ["http://mochi.test/tests/toolkit/components/extensions/test/mochitest/file_contentscript_*.html"],
|
||||
"js": ["content_script_idle.js"],
|
||||
"run_at": "document_idle"
|
||||
},
|
||||
{
|
||||
"matches": ["http://mochi.test/tests/toolkit/components/extensions/test/mochitest/file_contentscript_*.html"],
|
||||
"js": ["content_script.js"],
|
||||
"run_at": "document_idle"
|
||||
}
|
||||
],
|
||||
|
||||
"background": {
|
||||
"scripts": ["background.js"]
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
|
||||
# vim: set filetype=python:
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
TESTING_JS_MODULES.extensions.content_script += [
|
||||
'background.js',
|
||||
'content_script.js',
|
||||
'content_script_end.js',
|
||||
'content_script_idle.js',
|
||||
'content_script_start.js',
|
||||
'manifest.json',
|
||||
]
|
@ -6,7 +6,6 @@
|
||||
|
||||
DIRS += [
|
||||
'background',
|
||||
'content_script',
|
||||
'simple',
|
||||
'webrequest',
|
||||
]
|
||||
|
@ -1,12 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="test">Sample text</div>
|
||||
|
||||
</body>
|
||||
</html>
|
59
toolkit/components/extensions/test/mochitest/head.js
Normal file
59
toolkit/components/extensions/test/mochitest/head.js
Normal file
@ -0,0 +1,59 @@
|
||||
function testHandler(kind, pass, msg, ...args) {
|
||||
if (kind == "test-eq") {
|
||||
let [expected, actual] = args;
|
||||
SimpleTest.ok(pass, `${msg} - Expected: ${expected}, Actual: ${actual}`);
|
||||
} else if (kind == "test-log") {
|
||||
SimpleTest.info(msg);
|
||||
} else if (kind == "test-result") {
|
||||
SimpleTest.ok(pass, msg);
|
||||
}
|
||||
}
|
||||
|
||||
function loadExtension(name)
|
||||
{
|
||||
let testResolve;
|
||||
let testDone = new Promise(resolve => { testResolve = resolve; });
|
||||
|
||||
let messageResolve = new Map();
|
||||
|
||||
let handler = {
|
||||
testResult(kind, pass, msg, ...args) {
|
||||
if (kind == "test-done") {
|
||||
ok(pass, msg);
|
||||
return testResolve();
|
||||
}
|
||||
testHandler(kind, pass, msg, ...args);
|
||||
},
|
||||
|
||||
testMessage(msg, ...args) {
|
||||
let resolve = messageResolve.get(msg);
|
||||
if (!resolve) {
|
||||
return;
|
||||
}
|
||||
messageResolve.delete(msg);
|
||||
|
||||
resolve(...args);
|
||||
},
|
||||
};
|
||||
|
||||
let target = "resource://testing-common/extensions/" + name + "/";
|
||||
let resourceHandler = SpecialPowers.Services.io.getProtocolHandler("resource")
|
||||
.QueryInterface(SpecialPowers.Ci.nsISubstitutingProtocolHandler);
|
||||
let url = SpecialPowers.Services.io.newURI(target, null, null);
|
||||
let filePath = resourceHandler.resolveURI(url);
|
||||
|
||||
let extension = SpecialPowers.loadExtension(filePath, handler);
|
||||
|
||||
extension.awaitMessage = (msg) => {
|
||||
return new Promise(resolve => {
|
||||
messageResolve.set(msg, resolve);
|
||||
});
|
||||
};
|
||||
|
||||
extension.awaitFinish = () => {
|
||||
return testDone;
|
||||
};
|
||||
|
||||
SimpleTest.info(`Extension ${name} loaded`);
|
||||
return extension;
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
[DEFAULT]
|
||||
skip-if = os == 'android' || buildapp == 'b2g'
|
||||
support-files =
|
||||
head.js
|
||||
../extensions/**
|
||||
file_WebRequest_page1.html
|
||||
file_WebRequest_page2.html
|
||||
file_image_good.png
|
||||
@ -13,10 +15,6 @@ support-files =
|
||||
file_script_bad.js
|
||||
file_script_redirect.js
|
||||
file_script_xhr.js
|
||||
file_contentscript_page1.html
|
||||
|
||||
[test_simple_extensions.html]
|
||||
[test_extension_contentscript.html]
|
||||
[test_extension_webrequest.html]
|
||||
[test_generate_extension.html]
|
||||
[test_sandbox_var.html]
|
||||
|
@ -1,65 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test for content script</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/ExtensionTestUtils.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<script type="application/javascript;version=1.8">
|
||||
"use strict";
|
||||
|
||||
add_task(function* test_contentscript()
|
||||
{
|
||||
let extension = ExtensionTestUtils.loadExtension("content_script");
|
||||
yield extension.startup();
|
||||
info("extension loaded");
|
||||
|
||||
let loadingCount = 0;
|
||||
let interactiveCount = 0;
|
||||
let completeCount = 0;
|
||||
extension.onMessage("script-run-loading", () => { loadingCount++; });
|
||||
extension.onMessage("script-run-interactive", () => { interactiveCount++; });
|
||||
|
||||
let completePromise = new Promise(resolve => {
|
||||
extension.onMessage("script-run-complete", () => { completeCount++; resolve(); });
|
||||
});
|
||||
|
||||
let chromeNamespacePromise = extension.awaitMessage("chrome-namespace-ok");
|
||||
|
||||
yield new Promise(resolve => { setTimeout(resolve, 0); });
|
||||
|
||||
let win = window.open();
|
||||
|
||||
win.location = "file_contentscript_page1.html";
|
||||
|
||||
ok(true, "page loaded");
|
||||
|
||||
yield Promise.all([waitForLoad(win), completePromise, chromeNamespacePromise]);
|
||||
info("test page loaded");
|
||||
|
||||
win.close();
|
||||
|
||||
is(loadingCount, 1, "document_start script ran exactly once");
|
||||
is(interactiveCount, 1, "document_end script ran exactly once");
|
||||
is(completeCount, 1, "document_idle script ran exactly once");
|
||||
|
||||
yield extension.unload();
|
||||
info("extension unloaded");
|
||||
});
|
||||
|
||||
function waitForLoad(win) {
|
||||
return new Promise(resolve => {
|
||||
win.addEventListener("load", function listener() {
|
||||
win.removeEventListener("load", listener, true);
|
||||
resolve();
|
||||
}, true);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -4,7 +4,7 @@
|
||||
<title>Test for simple WebExtension</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/ExtensionTestUtils.js"></script>
|
||||
<script type="text/javascript;version=1.8" src="head.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
@ -75,7 +75,7 @@ function compareLists(list1, list2, kind)
|
||||
|
||||
function* test_once()
|
||||
{
|
||||
let extension = ExtensionTestUtils.loadExtension("webrequest");
|
||||
let extension = loadExtension("webrequest");
|
||||
yield extension.startup();
|
||||
yield extension.awaitMessage("ready");
|
||||
info("webrequest extension loaded");
|
||||
|
@ -1,48 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test for generating WebExtensions</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/ExtensionTestUtils.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<script type="application/javascript;version=1.8">
|
||||
|
||||
function backgroundScript() {
|
||||
browser.test.log("running background script");
|
||||
|
||||
browser.test.onMessage.addListener((x, y) => {
|
||||
browser.test.assertEq(x, 10, "x is 10");
|
||||
browser.test.assertEq(y, 20, "y is 20");
|
||||
|
||||
browser.test.notifyPass("background test passed");
|
||||
});
|
||||
|
||||
browser.test.sendMessage("running", 1);
|
||||
}
|
||||
|
||||
let extensionData = {
|
||||
background: "(" + backgroundScript.toString() + ")()"
|
||||
};
|
||||
|
||||
add_task(function* test_background() {
|
||||
let extension = ExtensionTestUtils.loadExtension(extensionData);
|
||||
info("load complete");
|
||||
yield extension.startup();
|
||||
let x = yield extension.awaitMessage("running");
|
||||
is(x, 1, "got correct value from extension");
|
||||
info("startup complete");
|
||||
extension.sendMessage(10, 20);
|
||||
yield extension.awaitFinish();
|
||||
info("test complete");
|
||||
yield extension.unload();
|
||||
info("extension unloaded successfully");
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -1,73 +0,0 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test for content script</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/ExtensionTestUtils.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<script type="application/javascript;version=1.8">
|
||||
"use strict";
|
||||
|
||||
function backgroundScript() {
|
||||
browser.runtime.onMessage.addListener(result => {
|
||||
browser.test.assertEq(result, 12, "x is 12");
|
||||
browser.test.notifyPass("background test passed");
|
||||
});
|
||||
}
|
||||
|
||||
function contentScript() {
|
||||
window.x = 12;
|
||||
browser.runtime.onMessage.addListener(function() {});
|
||||
browser.runtime.sendMessage(window.x);
|
||||
}
|
||||
|
||||
let extensionData = {
|
||||
background: "(" + backgroundScript.toString() + ")()",
|
||||
manifest: {
|
||||
"content_scripts": [{
|
||||
"matches": ["http://mochi.test/tests/toolkit/components/extensions/test/mochitest/file_contentscript_*.html"],
|
||||
"js": ["content_script.js"],
|
||||
"run_at": "document_start"
|
||||
}]
|
||||
},
|
||||
|
||||
files: {
|
||||
"content_script.js": "(" + contentScript.toString() + ")()",
|
||||
},
|
||||
};
|
||||
|
||||
add_task(function* test_contentscript() {
|
||||
let extension = ExtensionTestUtils.loadExtension(extensionData);
|
||||
yield extension.startup();
|
||||
info("extension loaded");
|
||||
|
||||
yield new Promise(resolve => { setTimeout(resolve, 0); });
|
||||
|
||||
let win = window.open();
|
||||
|
||||
win.location = "file_contentscript_page1.html";
|
||||
|
||||
yield Promise.all([waitForLoad(win), extension.awaitFinish()]);
|
||||
|
||||
win.close();
|
||||
|
||||
yield extension.unload();
|
||||
info("extension unloaded");
|
||||
});
|
||||
|
||||
function waitForLoad(win) {
|
||||
return new Promise(resolve => {
|
||||
win.addEventListener("load", function listener() {
|
||||
win.removeEventListener("load", listener, true);
|
||||
resolve();
|
||||
}, true);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -4,7 +4,7 @@
|
||||
<title>Test for simple WebExtension</title>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/SpawnTask.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/ExtensionTestUtils.js"></script>
|
||||
<script type="text/javascript;version=1.8" src="head.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
@ -12,7 +12,7 @@
|
||||
<script type="application/javascript;version=1.8">
|
||||
|
||||
add_task(function* test_simple() {
|
||||
let extension = ExtensionTestUtils.loadExtension("simple");
|
||||
let extension = loadExtension("simple");
|
||||
info("load complete");
|
||||
yield extension.startup();
|
||||
info("startup complete");
|
||||
@ -21,7 +21,7 @@ add_task(function* test_simple() {
|
||||
});
|
||||
|
||||
add_task(function* test_background() {
|
||||
let extension = ExtensionTestUtils.loadExtension("background");
|
||||
let extension = loadExtension("background");
|
||||
info("load complete");
|
||||
yield extension.startup();
|
||||
let x = yield extension.awaitMessage("running");
|
||||
|
Loading…
Reference in New Issue
Block a user