mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Merge fx-team to m-c. a=merge
This commit is contained in:
commit
847a505a01
2
addon-sdk/source/app-extension/bootstrap.js
vendored
2
addon-sdk/source/app-extension/bootstrap.js
vendored
@ -26,6 +26,8 @@ const appInfo = Cc["@mozilla.org/xre/app-info;1"].
|
||||
const vc = Cc["@mozilla.org/xpcom/version-comparator;1"].
|
||||
getService(Ci.nsIVersionComparator);
|
||||
|
||||
const Startup = Cu.import("resource://gre/modules/sdk/system/Startup.js", {}).exports;
|
||||
|
||||
|
||||
const REASON = [ 'unknown', 'startup', 'shutdown', 'enable', 'disable',
|
||||
'install', 'uninstall', 'upgrade', 'downgrade' ];
|
||||
|
@ -6,7 +6,7 @@ module.metadata = {
|
||||
"stability": "experimental"
|
||||
};
|
||||
|
||||
const { Cc, Ci } = require('chrome');
|
||||
const { Cc, Ci, Cu } = require('chrome');
|
||||
const { isNative } = require('@loader/options');
|
||||
const { descriptor, Sandbox, evaluate, main, resolveURI } = require('toolkit/loader');
|
||||
const { once } = require('../system/events');
|
||||
@ -21,24 +21,7 @@ const appShellService = Cc['@mozilla.org/appshell/appShellService;1'].
|
||||
getService(Ci.nsIAppShellService);
|
||||
const { preferences } = metadata;
|
||||
|
||||
const NAME2TOPIC = {
|
||||
'Firefox': 'sessionstore-windows-restored',
|
||||
'Fennec': 'sessionstore-windows-restored',
|
||||
'SeaMonkey': 'sessionstore-windows-restored',
|
||||
'Thunderbird': 'mail-startup-done'
|
||||
};
|
||||
|
||||
// Set 'final-ui-startup' as default topic for unknown applications
|
||||
let appStartup = 'final-ui-startup';
|
||||
|
||||
// Gets the topic that fit best as application startup event, in according with
|
||||
// the current application (e.g. Firefox, Fennec, Thunderbird...)
|
||||
for (let name of Object.keys(NAME2TOPIC)) {
|
||||
if (xulApp.is(name)) {
|
||||
appStartup = NAME2TOPIC[name];
|
||||
break;
|
||||
}
|
||||
}
|
||||
const Startup = Cu.import("resource://gre/modules/sdk/system/Startup.js", {}).exports;
|
||||
|
||||
// Initializes default preferences
|
||||
function setDefaultPrefs(prefsURI) {
|
||||
@ -74,26 +57,7 @@ function definePseudo(loader, id, exports) {
|
||||
loader.modules[uri] = { exports: exports };
|
||||
}
|
||||
|
||||
function wait(reason, options) {
|
||||
once(appStartup, function() {
|
||||
startup(null, options);
|
||||
});
|
||||
}
|
||||
|
||||
function startup(reason, options) {
|
||||
// Try accessing hidden window to guess if we are running during firefox
|
||||
// startup, so that we should wait for session restore event before
|
||||
// running the addon
|
||||
let initialized = false;
|
||||
try {
|
||||
appShellService.hiddenDOMWindow;
|
||||
initialized = true;
|
||||
}
|
||||
catch(e) {}
|
||||
if (reason === 'startup' || !initialized) {
|
||||
return wait(reason, options);
|
||||
}
|
||||
|
||||
function startup(reason, options) Startup.onceInitialized.then(() => {
|
||||
// Inject globals ASAP in order to have console API working ASAP
|
||||
Object.defineProperties(options.loader.globals, descriptor(globals));
|
||||
|
||||
@ -117,7 +81,7 @@ function startup(reason, options) {
|
||||
run(options);
|
||||
}).then(null, console.exception);
|
||||
return void 0; // otherwise we raise a warning, see bug 910304
|
||||
}
|
||||
});
|
||||
|
||||
function run(options) {
|
||||
try {
|
||||
|
55
addon-sdk/source/modules/system/Startup.js
Normal file
55
addon-sdk/source/modules/system/Startup.js
Normal file
@ -0,0 +1,55 @@
|
||||
/* 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/. */
|
||||
"use strict";
|
||||
|
||||
var EXPORTED_SYMBOLS = ["Startup"];
|
||||
|
||||
const { utils: Cu, interfaces: Ci, classes: Cc } = Components;
|
||||
const { Services } = Cu.import("resource://gre/modules/Services.jsm", {});
|
||||
const { XulApp } = Cu.import("resource://gre/modules/sdk/system/XulApp.js", {});
|
||||
const { defer } = Cu.import("resource://gre/modules/Promise.jsm", {}).Promise;
|
||||
|
||||
const appStartupSrv = Cc["@mozilla.org/toolkit/app-startup;1"]
|
||||
.getService(Ci.nsIAppStartup);
|
||||
|
||||
const NAME2TOPIC = {
|
||||
'Firefox': 'sessionstore-windows-restored',
|
||||
'Fennec': 'sessionstore-windows-restored',
|
||||
'SeaMonkey': 'sessionstore-windows-restored',
|
||||
'Thunderbird': 'mail-startup-done'
|
||||
};
|
||||
|
||||
var Startup = {
|
||||
initialized: !appStartupSrv.startingUp
|
||||
};
|
||||
var exports = Startup;
|
||||
|
||||
let gOnceInitializedDeferred = defer();
|
||||
exports.onceInitialized = gOnceInitializedDeferred.promise;
|
||||
|
||||
// Set 'final-ui-startup' as default topic for unknown applications
|
||||
let appStartup = 'final-ui-startup';
|
||||
|
||||
if (Startup.initialized) {
|
||||
gOnceInitializedDeferred.resolve()
|
||||
}
|
||||
else {
|
||||
// Gets the topic that fit best as application startup event, in according with
|
||||
// the current application (e.g. Firefox, Fennec, Thunderbird...)
|
||||
for (let name of Object.keys(NAME2TOPIC)) {
|
||||
if (XulApp.is(name)) {
|
||||
appStartup = NAME2TOPIC[name];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
let listener = function (subject, topic) {
|
||||
Services.obs.removeObserver(this, topic);
|
||||
Startup.initialized = true;
|
||||
Services.tm.currentThread.dispatch(() => gOnceInitializedDeferred.resolve(),
|
||||
Ci.nsIThread.DISPATCH_NORMAL);
|
||||
}
|
||||
|
||||
Services.obs.addObserver(listener, appStartup, false);
|
||||
}
|
@ -5,5 +5,6 @@
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
EXTRA_JS_MODULES.sdk.system += [
|
||||
'Startup.js',
|
||||
'XulApp.js',
|
||||
]
|
||||
|
19
addon-sdk/source/test/test-system-startup.js
Normal file
19
addon-sdk/source/test/test-system-startup.js
Normal file
@ -0,0 +1,19 @@
|
||||
/* 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/. */
|
||||
"use strict";
|
||||
|
||||
const { Cu } = require("chrome");
|
||||
const Startup = Cu.import("resource://gre/modules/sdk/system/Startup.js", {}).exports;
|
||||
|
||||
exports["test startup initialized"] = function(assert) {
|
||||
assert.ok(Startup.initialized, "Startup.initialized is true");
|
||||
}
|
||||
|
||||
exports["test startup onceInitialized"] = function*(assert) {
|
||||
yield Startup.onceInitialized.then(() => {
|
||||
assert.pass("onceInitialized promise was resolved");
|
||||
}).catch(assert.fail);
|
||||
}
|
||||
|
||||
require('sdk/test').run(exports);
|
@ -896,9 +896,10 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Use documentURIObject in the check for shouldLoadFavIcon so that we
|
||||
// do the right thing with about:-style error pages. Bug 453442
|
||||
else if (this.shouldLoadFavIcon(documentURI)) {
|
||||
if (!icon && this.shouldLoadFavIcon(documentURI)) {
|
||||
let url = documentURI.prePath + "/favicon.ico";
|
||||
if (!this.isFailedIcon(url))
|
||||
icon = url;
|
||||
|
@ -337,7 +337,7 @@ class MochitestRunner(MozbuildObject):
|
||||
manifest = TestManifest()
|
||||
manifest.tests.extend(tests)
|
||||
|
||||
if (len(tests) == 1):
|
||||
if len(tests) == 1:
|
||||
options.closeWhenDone = False
|
||||
|
||||
options.manifestFile = manifest
|
||||
|
@ -517,9 +517,11 @@ TestRunner.runTests = function (/*url...*/) {
|
||||
var singleTestRun = this._urls.length <= 1 && TestRunner.repeat <= 1;
|
||||
TestRunner.showTestReport = singleTestRun;
|
||||
var frame = $('testframe');
|
||||
frame.src="";
|
||||
frame.src = "";
|
||||
if (singleTestRun) {
|
||||
document.body.setAttribute("singletest", singleTestRun);
|
||||
// Can't use document.body because this runs in a XUL doc as well...
|
||||
var body = document.getElementsByTagName("body")[0];
|
||||
body.setAttribute("singletest", "true");
|
||||
frame.removeAttribute("scrolling");
|
||||
}
|
||||
TestRunner._checkForHangs();
|
||||
|
Loading…
Reference in New Issue
Block a user