mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-11 17:57:32 +09:00
Move WebExtensions enabled Add-ons Manager
This commit is contained in:
parent
d7d16e7fbb
commit
358cd0404a
1100 changed files with 133 additions and 106 deletions
|
|
@ -0,0 +1,7 @@
|
|||
"use strict";
|
||||
|
||||
module.exports = { // eslint-disable-line no-undef
|
||||
"extends": [
|
||||
"../../../../../testing/mochitest/mochitest.eslintrc.js"
|
||||
]
|
||||
};
|
||||
BIN
toolkit/mozapps/webextensions/test/mochitest/file_bug687194.xpi
Normal file
BIN
toolkit/mozapps/webextensions/test/mochitest/file_bug687194.xpi
Normal file
Binary file not shown.
|
|
@ -0,0 +1,2 @@
|
|||
<!DOCTYPE html>
|
||||
<html><head></head><body><span id="text">Nothing to see here</span></body></html>
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
[DEFAULT]
|
||||
support-files =
|
||||
file_empty.html
|
||||
file_bug687194.xpi
|
||||
|
||||
[test_bug609794.html]
|
||||
[test_bug687194.html]
|
||||
skip-if = e10s || os == "android" # this test creates its own child process, no need to run it in e10s
|
||||
[test_bug887098.html]
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=609794
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 609794</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=609794">Mozilla Bug 609794</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 609794 **/
|
||||
var obj = Object.create(window);
|
||||
is(Object.prototype.toString.call(obj.InstallTrigger), "[object InstallTriggerImpl]", "can get InstallTrigger through the prototype");
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
133
toolkit/mozapps/webextensions/test/mochitest/test_bug687194.html
Normal file
133
toolkit/mozapps/webextensions/test/mochitest/test_bug687194.html
Normal file
|
|
@ -0,0 +1,133 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<title>Test for registering/unregistering chrome OOP</title>
|
||||
<script type="application/javascript"
|
||||
src="/tests/SimpleTest/SimpleTest.js">
|
||||
</script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<script type="application/javascript;version=1.8">
|
||||
"use strict";
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
const childFrameURL =
|
||||
"data:text/html,<!DOCTYPE HTML><html><body></body></html>";
|
||||
|
||||
function childFrameScript() {
|
||||
"use strict";
|
||||
|
||||
var ios =
|
||||
Components.classes["@mozilla.org/network/io-service;1"]
|
||||
.getService(Components.interfaces.nsIIOService);
|
||||
let cr =
|
||||
Components.classes["@mozilla.org/chrome/chrome-registry;1"]
|
||||
.getService(Ci.nsIXULChromeRegistry);
|
||||
addMessageListener("test687194:resolveChromeURI", function(message) {
|
||||
let result;
|
||||
let threw = false;
|
||||
try {
|
||||
let uri = ios.newURI(message.data.URI, null, null);
|
||||
result = cr.convertChromeURL(uri).spec;
|
||||
} catch (e) {
|
||||
threw = true;
|
||||
result = "EXCEPTION: " + e;
|
||||
}
|
||||
|
||||
message.target.sendAsyncMessage("test687194:resolveChromeURI:Answer",
|
||||
{ threw: threw, result: result });
|
||||
});
|
||||
}
|
||||
|
||||
let test;
|
||||
function* testStructure(mm) {
|
||||
let lastResult;
|
||||
|
||||
mm.addMessageListener("test687194:resolveChromeURI:Answer", function(msg) {
|
||||
test.next(msg.data);
|
||||
});
|
||||
|
||||
mm.sendAsyncMessage("test687194:resolveChromeURI",
|
||||
{ URI: "chrome://bug687194/content/e10sbug.js" });
|
||||
lastResult = yield;
|
||||
is(lastResult.threw, true, "URI shouldn't resolve to begin with");
|
||||
|
||||
let { AddonManager } = SpecialPowers.Cu.import("resource://gre/modules/AddonManager.jsm", {});
|
||||
const INSTALL_URI =
|
||||
"http://mochi.test:8888/tests/toolkit/mozapps/extensions/test/mochitest/file_bug687194.xpi"
|
||||
AddonManager.getInstallForURL(INSTALL_URI, (install) => {
|
||||
install = SpecialPowers.wrap(install);
|
||||
install.addListener(SpecialPowers.wrapCallbackObject({
|
||||
onInstallEnded: function(install, addon) {
|
||||
SimpleTest.executeSoon(() => test.next(addon));
|
||||
}
|
||||
}));
|
||||
install.install();
|
||||
}, "application/x-xpinstall");
|
||||
|
||||
let addon = SpecialPowers.wrap(yield);
|
||||
|
||||
mm.sendAsyncMessage("test687194:resolveChromeURI",
|
||||
{ URI: "chrome://bug687194/content/e10sbug.js" });
|
||||
lastResult = yield;
|
||||
is(lastResult.threw, false, "able to resolve after the installation");
|
||||
|
||||
let listener = SpecialPowers.wrapCallbackObject({
|
||||
onUninstalled: function(removedAddon) {
|
||||
if (removedAddon.id === addon.id) {
|
||||
AddonManager.removeAddonListener(listener);
|
||||
SimpleTest.executeSoon(() => test.next());
|
||||
}
|
||||
}
|
||||
});
|
||||
AddonManager.addAddonListener(listener);
|
||||
addon.uninstall();
|
||||
|
||||
yield;
|
||||
|
||||
mm.sendAsyncMessage("test687194:resolveChromeURI",
|
||||
{ URI: "chrome://bug687194/content/e10sbug.js" });
|
||||
lastResult = yield;
|
||||
is(lastResult.threw, true, "should have unregistered the URI");
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
function runTests() {
|
||||
info("Browser prefs set.");
|
||||
|
||||
let iframe = document.createElement("iframe");
|
||||
SpecialPowers.wrap(iframe).mozbrowser = true;
|
||||
iframe.id = "iframe";
|
||||
iframe.src = childFrameURL;
|
||||
|
||||
iframe.addEventListener("mozbrowserloadend", function() {
|
||||
info("Got iframe load event.");
|
||||
let mm = SpecialPowers.getBrowserFrameMessageManager(iframe);
|
||||
mm.loadFrameScript("data:,(" + childFrameScript.toString() + ")();",
|
||||
false);
|
||||
|
||||
test = testStructure(mm);
|
||||
test.next();
|
||||
});
|
||||
|
||||
document.body.appendChild(iframe);
|
||||
}
|
||||
|
||||
addEventListener("load", function() {
|
||||
info("Got load event.");
|
||||
|
||||
SpecialPowers.addPermission("browser", true, document);
|
||||
SpecialPowers.pushPrefEnv({
|
||||
"set": [
|
||||
["dom.ipc.browser_frames.oop_by_default", true],
|
||||
["dom.mozBrowserFramesEnabled", true],
|
||||
["browser.pagethumbnails.capturing_disabled", true]
|
||||
]
|
||||
}, runTests);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=887098
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 887098</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 887098 **/
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
/* globals $,evalRef */
|
||||
|
||||
function loaded() {
|
||||
var iwin = $('ifr').contentWindow;
|
||||
var href = SpecialPowers.wrap(iwin).location.href;
|
||||
if (/file_empty/.test(href)) {
|
||||
window.evalRef = iwin.eval;
|
||||
window.installTriggerRef = iwin.InstallTrigger; // Force lazy instantiation.
|
||||
// about: is privileged, so we need to be privileged to load it.
|
||||
SpecialPowers.wrap(iwin).location.href = 'about:';
|
||||
} else {
|
||||
is(href, 'about:', "Successfully navigated to about:");
|
||||
try {
|
||||
evalRef('InstallTrigger.install({URL: "chrome://global/skin/global.css"});');
|
||||
ok(false, "Should have thrown when trying to install restricted URI from InstallTrigger");
|
||||
} catch (e) {
|
||||
// XXXgijs this test broke because of the switch to webidl. I'm told
|
||||
// it has to do with compartments and the fact that we eval in "about:".
|
||||
// Tracking in bug 1007671
|
||||
todo(/permission/.test(e), "We should throw a security exception. Got: " + e);
|
||||
}
|
||||
SimpleTest.finish();
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=887098">Mozilla Bug 887098</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<iframe onload="loaded();" id="ifr" src="file_empty.html"></iframe>
|
||||
<pre id="test">
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue