mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 912698 - Uplift Add-on SDK to Firefox r=me
This commit is contained in:
parent
68f38de585
commit
11f2ce2bf0
@ -12,14 +12,24 @@ const { make: makeWindow, getHiddenWindow } = require("../window/utils");
|
||||
const { create: makeFrame, getDocShell } = require("../frame/utils");
|
||||
const { defer } = require("../core/promise");
|
||||
const { when: unload } = require("../system/unload");
|
||||
const cfxArgs = require("@test/options");
|
||||
|
||||
let addonPrincipal = Cc["@mozilla.org/systemprincipal;1"].
|
||||
createInstance(Ci.nsIPrincipal);
|
||||
|
||||
let hiddenWindow = getHiddenWindow();
|
||||
|
||||
if (cfxArgs.parseable) {
|
||||
console.info("hiddenWindow document.documentURI:" +
|
||||
hiddenWindow.document.documentURI);
|
||||
console.info("hiddenWindow document.readyState:" +
|
||||
hiddenWindow.document.readyState);
|
||||
}
|
||||
|
||||
// Once Bug 565388 is fixed and shipped we'll be able to make invisible,
|
||||
// permanent docShells. Meanwhile we create hidden top level window and
|
||||
// use it's docShell.
|
||||
let frame = makeFrame(getHiddenWindow().document, {
|
||||
let frame = makeFrame(hiddenWindow.document, {
|
||||
nodeName: "iframe",
|
||||
namespaceURI: "http://www.w3.org/1999/xhtml",
|
||||
allowJavascript: true,
|
||||
|
@ -2,4 +2,4 @@ let { deprecateUsage } = require("../util/deprecate");
|
||||
|
||||
deprecateUsage("Module 'sdk/page-mod/match-pattern' is deprecated use 'sdk/util/match-pattern' instead");
|
||||
|
||||
module.exports = require("../page-mod/match-pattern");
|
||||
module.exports = require("../util/match-pattern");
|
||||
|
@ -260,6 +260,7 @@ const load = iced(function load(loader, module) {
|
||||
let stack = error.stack || Error().stack;
|
||||
let frames = parseStack(stack).filter(isntLoaderFrame);
|
||||
let toString = String(error);
|
||||
let file = sourceURI(fileName);
|
||||
|
||||
// Note that `String(error)` where error is from subscript loader does
|
||||
// not puts `:` after `"Error"` unlike regular errors thrown by JS code.
|
||||
@ -272,6 +273,13 @@ const load = iced(function load(loader, module) {
|
||||
message = "Module `" + module.id + "` is not found at " + module.uri;
|
||||
toString = message;
|
||||
}
|
||||
// Workaround for a Bug 910653. Errors thrown by subscript loader
|
||||
// do not include `stack` field and above created error won't have
|
||||
// fileName or lineNumber of the module being loaded, so we ensure
|
||||
// it does.
|
||||
else if (frames[frames.length - 1].fileName !== file) {
|
||||
frames.push({ fileName: file, lineNumber: lineNumber, name: "" });
|
||||
}
|
||||
|
||||
let prototype = typeof(error) === "object" ? error.constructor.prototype :
|
||||
Error.prototype;
|
||||
|
@ -4,4 +4,8 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
module.metadata = {
|
||||
"status": "experimental"
|
||||
};
|
||||
|
||||
exports.b = @ require('b');
|
||||
|
@ -31,12 +31,15 @@ exports['test syntax errors'] = function(assert) {
|
||||
assert.equal(error.name, "SyntaxError", "throws syntax error");
|
||||
assert.equal(error.fileName.split("/").pop(), "error.js",
|
||||
"Error contains filename");
|
||||
assert.equal(error.lineNumber, 7, "error is on line 7")
|
||||
assert.equal(error.lineNumber, 11, "error is on line 11")
|
||||
let stack = parseStack(error.stack);
|
||||
|
||||
assert.equal(stack.pop().fileName, uri + "error.js",
|
||||
"last frame file containing syntax error");
|
||||
assert.equal(stack.pop().fileName, uri + "main.js",
|
||||
"loader stack is omitted");
|
||||
"previous frame is a requirer module");
|
||||
assert.equal(stack.pop().fileName, module.uri,
|
||||
"previous in the stack is test module");
|
||||
"previous to it is a test module");
|
||||
|
||||
} finally {
|
||||
unload(loader);
|
||||
|
@ -203,7 +203,13 @@ exports["test Parent Resize Hack"] = function(assert, done) {
|
||||
timer.setTimeout(function () {
|
||||
assert.equal(previousWidth,browserWindow.outerWidth,"Size doesn't change by calling resizeTo/By/...");
|
||||
assert.equal(previousHeight,browserWindow.outerHeight,"Size doesn't change by calling resizeTo/By/...");
|
||||
panel.destroy();
|
||||
try {
|
||||
panel.destroy();
|
||||
}
|
||||
catch (e) {
|
||||
console.exception(e);
|
||||
throw e;
|
||||
}
|
||||
done();
|
||||
},0);
|
||||
}
|
||||
|
@ -2,28 +2,62 @@
|
||||
* 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/. */
|
||||
|
||||
const traceback = require("sdk/console/traceback");
|
||||
'use strict';
|
||||
|
||||
exports.test_no_args = function(test) {
|
||||
var passed = false;
|
||||
const traceback = require('sdk/console/traceback');
|
||||
const REQUIRE_LINE_NO = 30;
|
||||
|
||||
exports.test_no_args = function(assert) {
|
||||
let passed = tryRequireModule(assert);
|
||||
assert.ok(passed, 'require() with no args should raise helpful error');
|
||||
};
|
||||
|
||||
exports.test_invalid_sdk_module = function (assert) {
|
||||
let passed = tryRequireModule(assert, 'sdk/does-not-exist');
|
||||
assert.ok(passed, 'require() with an invalid sdk module should raise');
|
||||
};
|
||||
|
||||
exports.test_invalid_relative_module = function (assert) {
|
||||
let passed = tryRequireModule(assert, './does-not-exist');
|
||||
assert.ok(passed, 'require() with an invalid relative module should raise');
|
||||
};
|
||||
|
||||
|
||||
function tryRequireModule(assert, module) {
|
||||
let passed = false;
|
||||
try {
|
||||
var oops = require(); // leave this on line 6!
|
||||
// This line number is important, referenced in REQUIRE_LINE_NO
|
||||
let doesNotExist = require(module);
|
||||
} catch(e) {
|
||||
let msg = e.toString();
|
||||
test.assertEqual(msg.indexOf("Error: you must provide a module name when calling require() from "), 0);
|
||||
test.assertNotEqual(msg.indexOf("test-require"), -1, msg);
|
||||
// we'd also like to assert that the right filename and linenumber is in
|
||||
// the stack trace, but this currently doesn't work (see bugs 679591 and
|
||||
// 551604)
|
||||
if (0) {
|
||||
let tb = traceback.fromException(e);
|
||||
let lastFrame = tb[tb.length-1];
|
||||
test.assertNotEqual(lastFrame.filename.indexOf("test-require.js"), -1,
|
||||
lastFrame.filename);
|
||||
test.assertEqual(lastFrame.lineNo, 6);
|
||||
test.assertEqual(lastFrame.funcName, "??");
|
||||
}
|
||||
checkError(assert, module, e);
|
||||
passed = true;
|
||||
}
|
||||
test.assert(passed, 'require() with no args should raise helpful error');
|
||||
};
|
||||
return passed;
|
||||
}
|
||||
|
||||
function checkError (assert, name, e) {
|
||||
let msg = e.toString();
|
||||
if (name) {
|
||||
assert.ok(/is not found at/.test(msg),
|
||||
'Error message indicates module not found');
|
||||
assert.ok(msg.indexOf(name.replace(/\./g,'')) > -1,
|
||||
'Error message has the invalid module name in the message');
|
||||
}
|
||||
else {
|
||||
assert.equal(msg.indexOf('Error: you must provide a module name when calling require() from '), 0);
|
||||
assert.ok(msg.indexOf("test-require") !== -1, msg);
|
||||
}
|
||||
|
||||
// we'd also like to assert that the right filename
|
||||
// and linenumber is in the stacktrace
|
||||
let tb = traceback.fromException(e);
|
||||
// Get the second to last frame, as the last frame is inside
|
||||
// toolkit/loader
|
||||
let lastFrame = tb[tb.length-2];
|
||||
assert.ok(lastFrame.fileName.indexOf("test-require.js") !== -1,
|
||||
'Filename found in stacktrace');
|
||||
assert.equal(lastFrame.lineNumber, REQUIRE_LINE_NO,
|
||||
'stacktrace has correct line number');
|
||||
}
|
||||
|
||||
require('test').run(exports);
|
||||
|
@ -20,8 +20,8 @@ function getWidget(buttonId, window = getMostRecentBrowserWindow()) {
|
||||
const { CustomizableUI } = Cu.import('resource:///modules/CustomizableUI.jsm', {});
|
||||
const { AREA_NAVBAR } = CustomizableUI;
|
||||
|
||||
let widgets = CustomizableUI.getWidgetsInArea(AREA_NAVBAR).
|
||||
filter(({id}) => id.startsWith('button--') && id.endsWith(buttonId));
|
||||
let widgets = CustomizableUI.getWidgetIdsInArea(AREA_NAVBAR).
|
||||
filter((id) => id.startsWith('button--') && id.endsWith(buttonId));
|
||||
|
||||
if (widgets.length === 0)
|
||||
throw new Error('Widget with id `' + id +'` not found.');
|
||||
@ -29,7 +29,7 @@ function getWidget(buttonId, window = getMostRecentBrowserWindow()) {
|
||||
if (widgets.length > 1)
|
||||
throw new Error('Unexpected number of widgets: ' + widgets.length)
|
||||
|
||||
return widgets[0].forWindow(window);
|
||||
return CustomizableUI.getWidget(widgets[0]).forWindow(window);
|
||||
};
|
||||
|
||||
exports['test basic constructor validation'] = function(assert) {
|
||||
|
Loading…
Reference in New Issue
Block a user