Bug 1199800 - [webext] More refactoring of SpecialPowers to support chrome tests (r=gabor)

This commit is contained in:
Bill McCloskey 2015-08-27 16:21:36 -07:00
Родитель e416c237da
Коммит bc938037af
3 изменённых файлов: 10 добавлений и 13 удалений

Просмотреть файл

@ -37,13 +37,7 @@ ExtensionTestUtils.loadExtension = function(name)
},
};
var target = "resource://testing-common/extensions/" + name + "/";
var resourceHandler = SpecialPowers.Services.io.getProtocolHandler("resource")
.QueryInterface(SpecialPowers.Ci.nsISubstitutingProtocolHandler);
var url = SpecialPowers.Services.io.newURI(target, null, null);
var filePath = resourceHandler.resolveURI(url);
var extension = SpecialPowers.loadExtension(filePath, handler);
var extension = SpecialPowers.loadExtension(name, handler);
extension.awaitMessage = (msg) => {
return new Promise(resolve => {

Просмотреть файл

@ -560,7 +560,13 @@ SpecialPowersObserverAPI.prototype = {
let {Extension} = Components.utils.import("resource://gre/modules/Extension.jsm", {});
let id = aMessage.data.id;
let uri = Services.io.newURI(aMessage.data.url, null, null);
let name = aMessage.data.name;
let target = "resource://testing-common/extensions/" + name + "/";
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);
let extension = new Extension({
id,
resourceURI: uri

Просмотреть файл

@ -2044,7 +2044,7 @@ SpecialPowersAPI.prototype = {
this.notifyObserversInParentProcess(null, "browser:purge-domain-data", "example.com");
},
loadExtension: function(url, handler) {
loadExtension: function(name, handler) {
let uuidGenerator = Cc["@mozilla.org/uuid-generator;1"].getService(Ci.nsIUUIDGenerator);
let id = uuidGenerator.generateUUID().number;
@ -2059,9 +2059,6 @@ SpecialPowersAPI.prototype = {
let sp = this;
let extension = {
id,
url,
startup() {
sp._sendAsyncMessage("SPStartupExtension", {id});
return startupPromise;
@ -2077,7 +2074,7 @@ SpecialPowersAPI.prototype = {
},
};
this._sendAsyncMessage("SPLoadExtension", {url, id});
this._sendAsyncMessage("SPLoadExtension", {name, id});
let listener = (msg) => {
if (msg.data.id == id) {