зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1451519 Convert specialpowers to a webextension r=kmag
This is a quick-and-dirty port. It might be nice to replace SpecialPowersObserver with the webextensions content script injection system at some point, but that isn't practical right now (since WE experiments cannot implement new APIs visible to content scripts). MozReview-Commit-ID: GinCu3VcbWK --HG-- rename : testing/specialpowers/bootstrap.js => testing/specialpowers/api.js extra : rebase_source : 0faf7d21c8868c957ddc7fede0d56809f27dc161 extra : intermediate-source : ffb9ce93b92dd6396bfe038d3f6a8bcf929ec277 extra : source : cca596eadd0437dc75b75c119b6c7a405805f703
This commit is contained in:
Родитель
52a050c9e3
Коммит
07dcc1c764
|
@ -26,9 +26,9 @@ const whitelist = {
|
|||
modules: new Set([
|
||||
// From the test harness
|
||||
"chrome://mochikit/content/ShutdownLeaksCollector.jsm",
|
||||
"chrome://specialpowers/content/MockColorPicker.jsm",
|
||||
"chrome://specialpowers/content/MockFilePicker.jsm",
|
||||
"chrome://specialpowers/content/MockPermissionPrompt.jsm",
|
||||
"resource://specialpowers/MockColorPicker.jsm",
|
||||
"resource://specialpowers/MockFilePicker.jsm",
|
||||
"resource://specialpowers/MockPermissionPrompt.jsm",
|
||||
|
||||
// General utilities
|
||||
"resource://gre/modules/AppConstants.jsm",
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
"use strict";
|
||||
|
||||
let { MockFilePicker } =
|
||||
ChromeUtils.import("chrome://specialpowers/content/MockFilePicker.jsm", {});
|
||||
ChromeUtils.import("resource://specialpowers/MockFilePicker.jsm", {});
|
||||
|
||||
function parentReady(message) {
|
||||
MockFilePicker.init(content);
|
||||
|
|
|
@ -635,7 +635,7 @@ mozJSComponentLoader::ReuseGlobal(nsIURI* aURI)
|
|||
// which sets a per-compartment flag that disables certain
|
||||
// security wrappers, so don't use the shared global for them
|
||||
// to avoid breaking tests.
|
||||
if (FindInReadable(NS_LITERAL_CSTRING("chrome://specialpowers/"), spec)) {
|
||||
if (FindInReadable(NS_LITERAL_CSTRING("resource://specialpowers/"), spec)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
/* 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/. */
|
||||
|
||||
/* globals ExtensionAPI */
|
||||
|
||||
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyServiceGetter(this, "resProto",
|
||||
"@mozilla.org/network/protocol;1?name=resource",
|
||||
"nsISubstitutingProtocolHandler");
|
||||
|
||||
this.specialpowers = class extends ExtensionAPI {
|
||||
onStartup() {
|
||||
let uri = Services.io.newURI("content/", null, this.extension.rootURI);
|
||||
resProto.setSubstitutionWithFlags("specialpowers", uri,
|
||||
resProto.ALLOW_CONTENT_ACCESS);
|
||||
|
||||
ChromeUtils.import("resource://specialpowers/SpecialPowersObserver.jsm");
|
||||
this.observer = new SpecialPowersObserver();
|
||||
this.observer.init();
|
||||
}
|
||||
|
||||
onShutdown() {
|
||||
this.observer.uninit();
|
||||
this.observer = null;
|
||||
resProto.setSubstitution("specialpowers", null);
|
||||
}
|
||||
};
|
|
@ -1,39 +0,0 @@
|
|||
/* 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/. */
|
||||
|
||||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
var spObserver;
|
||||
|
||||
function startup(data, reason) {
|
||||
let observer = {};
|
||||
ChromeUtils.import("chrome://specialpowers/content/SpecialPowersObserver.jsm", observer);
|
||||
|
||||
let registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
|
||||
registrar.registerFactory(
|
||||
observer.SpecialPowersObserver.prototype.classID,
|
||||
"SpecialPowersObserver",
|
||||
observer.SpecialPowersObserver.prototype.contractID,
|
||||
observer.SpecialPowersObserverFactory
|
||||
);
|
||||
|
||||
spObserver = new observer.SpecialPowersObserver();
|
||||
spObserver.init();
|
||||
}
|
||||
|
||||
function shutdown(data, reason) {
|
||||
let observer = {};
|
||||
ChromeUtils.import("chrome://specialpowers/content/SpecialPowersObserver.jsm", observer);
|
||||
|
||||
let registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
|
||||
registrar.unregisterFactory(
|
||||
observer.SpecialPowersObserver.prototype.classID,
|
||||
observer.SpecialPowersObserverFactory
|
||||
);
|
||||
|
||||
spObserver.uninit();
|
||||
}
|
||||
|
||||
function install(data, reason) {}
|
||||
function uninstall(data, reason) {}
|
|
@ -11,19 +11,19 @@
|
|||
|
||||
/* import-globals-from SpecialPowersObserverAPI.js */
|
||||
|
||||
var EXPORTED_SYMBOLS = ["SpecialPowersObserver", "SpecialPowersObserverFactory"];
|
||||
var EXPORTED_SYMBOLS = ["SpecialPowersObserver"];
|
||||
|
||||
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
Cu.importGlobalProperties(["File"]);
|
||||
|
||||
const CHILD_SCRIPT = "chrome://specialpowers/content/specialpowers.js";
|
||||
const CHILD_SCRIPT_API = "chrome://specialpowers/content/specialpowersAPI.js";
|
||||
const CHILD_LOGGER_SCRIPT = "chrome://specialpowers/content/MozillaLogger.js";
|
||||
const CHILD_SCRIPT = "resource://specialpowers/specialpowers.js";
|
||||
const CHILD_SCRIPT_API = "resource://specialpowers/specialpowersAPI.js";
|
||||
const CHILD_LOGGER_SCRIPT = "resource://specialpowers/MozillaLogger.js";
|
||||
|
||||
|
||||
// Glue to add in the observer API to this object. This allows us to share code with chrome tests
|
||||
Services.scriptloader.loadSubScript("chrome://specialpowers/content/SpecialPowersObserverAPI.js");
|
||||
Services.scriptloader.loadSubScript("resource://specialpowers/SpecialPowersObserverAPI.js");
|
||||
|
||||
/* XPCOM gunk */
|
||||
function SpecialPowersObserver() {
|
||||
|
@ -34,9 +34,6 @@ function SpecialPowersObserver() {
|
|||
|
||||
SpecialPowersObserver.prototype = new SpecialPowersObserverAPI();
|
||||
|
||||
SpecialPowersObserver.prototype.classDescription = "Special powers Observer for use in testing.";
|
||||
SpecialPowersObserver.prototype.classID = Components.ID("{59a52458-13e0-4d93-9d85-a637344f29a1}");
|
||||
SpecialPowersObserver.prototype.contractID = "@mozilla.org/special-powers-observer;1";
|
||||
SpecialPowersObserver.prototype.QueryInterface = ChromeUtils.generateQI([Ci.nsIObserver]);
|
||||
|
||||
SpecialPowersObserver.prototype.observe = function(aSubject, aTopic, aData) {
|
||||
|
@ -289,12 +286,3 @@ SpecialPowersObserver.prototype.receiveMessage = function(aMessage) {
|
|||
}
|
||||
return undefined;
|
||||
};
|
||||
|
||||
var SpecialPowersObserverFactory = Object.freeze({
|
||||
createInstance(outer, id) {
|
||||
if (outer) { throw Cr.NS_ERROR_NO_AGGREGATION; }
|
||||
return new SpecialPowersObserver();
|
||||
},
|
||||
loadFactory(lock) {},
|
||||
QueryInterface: ChromeUtils.generateQI([Ci.nsIFactory])
|
||||
});
|
||||
|
|
|
@ -501,7 +501,7 @@ SpecialPowersObserverAPI.prototype = {
|
|||
Object.defineProperty(sb, "assert", {
|
||||
get() {
|
||||
let scope = Cu.createObjectIn(sb);
|
||||
Services.scriptloader.loadSubScript("chrome://specialpowers/content/Assert.jsm",
|
||||
Services.scriptloader.loadSubScript("resource://specialpowers/Assert.jsm",
|
||||
scope);
|
||||
|
||||
let assert = new scope.Assert(reporter);
|
||||
|
|
|
@ -217,9 +217,9 @@ SpecialPowers.prototype.nestedFrameSetup = function() {
|
|||
});
|
||||
});
|
||||
|
||||
mm.loadFrameScript("chrome://specialpowers/content/MozillaLogger.js", false);
|
||||
mm.loadFrameScript("chrome://specialpowers/content/specialpowersAPI.js", false);
|
||||
mm.loadFrameScript("chrome://specialpowers/content/specialpowers.js", false);
|
||||
mm.loadFrameScript("resource://specialpowers/MozillaLogger.js", false);
|
||||
mm.loadFrameScript("resource://specialpowers/specialpowersAPI.js", false);
|
||||
mm.loadFrameScript("resource://specialpowers/specialpowers.js", false);
|
||||
|
||||
let frameScript = "SpecialPowers.prototype.IsInNestedFrame=true;";
|
||||
mm.loadFrameScript("data:," + frameScript, false);
|
||||
|
|
|
@ -12,9 +12,9 @@
|
|||
|
||||
var global = this;
|
||||
|
||||
ChromeUtils.import("chrome://specialpowers/content/MockFilePicker.jsm");
|
||||
ChromeUtils.import("chrome://specialpowers/content/MockColorPicker.jsm");
|
||||
ChromeUtils.import("chrome://specialpowers/content/MockPermissionPrompt.jsm");
|
||||
ChromeUtils.import("resource://specialpowers/MockFilePicker.jsm");
|
||||
ChromeUtils.import("resource://specialpowers/MockColorPicker.jsm");
|
||||
ChromeUtils.import("resource://specialpowers/MockPermissionPrompt.jsm");
|
||||
ChromeUtils.import("resource://gre/modules/Services.jsm");
|
||||
ChromeUtils.import("resource://gre/modules/PrivateBrowsingUtils.jsm");
|
||||
ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
|
||||
<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:em="http://www.mozilla.org/2004/em-rdf#">
|
||||
|
||||
<Description about="urn:mozilla:install-manifest">
|
||||
<em:id>special-powers@mozilla.org</em:id>
|
||||
<em:version>2015.11.16</em:version>
|
||||
<em:type>2</em:type>
|
||||
<em:bootstrap>true</em:bootstrap>
|
||||
|
||||
<!-- Target Application this extension can install into,
|
||||
with minimum and maximum supported versions. -->
|
||||
<em:targetApplication>
|
||||
<Description>
|
||||
<em:id>toolkit@mozilla.org</em:id>
|
||||
#expand <em:minVersion>__MOZILLA_VERSION_U__</em:minVersion>
|
||||
<!-- Set to * so toolkit/mozapps/update/chrome tests pass. -->
|
||||
<em:maxVersion>*</em:maxVersion>
|
||||
</Description>
|
||||
</em:targetApplication>
|
||||
|
||||
<!-- Front End MetaData -->
|
||||
<em:name>Special Powers</em:name>
|
||||
<em:description>Special powers for use in testing.</em:description>
|
||||
<em:creator>Mozilla</em:creator>
|
||||
</Description>
|
||||
</RDF>
|
|
@ -1,11 +0,0 @@
|
|||
specialpowers.jar:
|
||||
% content specialpowers %content/ contentaccessible=true
|
||||
content/specialpowers.js (content/specialpowers.js)
|
||||
content/specialpowersAPI.js (content/specialpowersAPI.js)
|
||||
content/SpecialPowersObserverAPI.js (content/SpecialPowersObserverAPI.js)
|
||||
content/SpecialPowersObserver.jsm (content/SpecialPowersObserver.jsm)
|
||||
content/MozillaLogger.js (content/MozillaLogger.js)
|
||||
content/MockFilePicker.jsm (content/MockFilePicker.jsm)
|
||||
content/MockColorPicker.jsm (content/MockColorPicker.jsm)
|
||||
content/MockPermissionPrompt.jsm (content/MockPermissionPrompt.jsm)
|
||||
content/Assert.jsm (../modules/Assert.jsm)
|
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"manifest_version": 2,
|
||||
"name": "Special Powers",
|
||||
"version": "2018.06.27",
|
||||
|
||||
"applications": {
|
||||
"gecko": {
|
||||
"id": "special-powers@mozilla.org"
|
||||
}
|
||||
},
|
||||
"permissions": [],
|
||||
|
||||
"experiment_apis": {
|
||||
"specialpowers": {
|
||||
"schema": "schema.json",
|
||||
"parent": {
|
||||
"scopes": ["addon_parent"],
|
||||
"script": "api.js",
|
||||
"events": ["startup"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,17 +6,25 @@
|
|||
|
||||
XPI_NAME = 'specialpowers'
|
||||
|
||||
JAR_MANIFESTS += ['jar.mn']
|
||||
|
||||
USE_EXTENSION_MANIFEST = True
|
||||
NO_JS_MANIFEST = True
|
||||
|
||||
FINAL_TARGET_PP_FILES += [
|
||||
'install.rdf',
|
||||
FINAL_TARGET_FILES += [
|
||||
'api.js',
|
||||
'manifest.json',
|
||||
'schema.json',
|
||||
]
|
||||
|
||||
FINAL_TARGET_FILES += [
|
||||
'bootstrap.js',
|
||||
FINAL_TARGET_FILES.content += [
|
||||
'../modules/Assert.jsm',
|
||||
'content/MockColorPicker.jsm',
|
||||
'content/MockFilePicker.jsm',
|
||||
'content/MockPermissionPrompt.jsm',
|
||||
'content/MozillaLogger.js',
|
||||
'content/specialpowers.js',
|
||||
'content/specialpowersAPI.js',
|
||||
'content/SpecialPowersObserver.jsm',
|
||||
'content/SpecialPowersObserverAPI.js',
|
||||
]
|
||||
|
||||
with Files("**"):
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
[]
|
Загрузка…
Ссылка в новой задаче