Skip to content

Commit

Permalink
Bug 1793227, part 3 - Automatic fixes for js/xpconnect/tests/chrome. …
Browse files Browse the repository at this point in the history
…r=kmag

Also change .eslintignore to cover the other directories.

This also fixes the indentation the automatic fixer messed up in a few XHTML files.

Differential Revision: https://phabricator.services.mozilla.com/D158503
  • Loading branch information
amccreight committed Oct 10, 2022
1 parent a2486ee commit d8c43d0
Show file tree
Hide file tree
Showing 26 changed files with 98 additions and 96 deletions.
7 changes: 6 additions & 1 deletion .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,17 @@ intl/l10n/
# Exclude everything but self-hosted JS
js/examples/
js/public/
js/xpconnect/
js/src/devtools/
js/src/jit-test/
js/src/tests/
js/src/Y.js

# Changes to XPConnect tests must be carefully audited.
js/xpconnect/loader/
js/xpconnect/tests/browser/
js/xpconnect/tests/mochitest/
js/xpconnect/tests/unit/

# Fuzzing code for testing only, targeting the JS shell
js/src/fuzz-tests/

Expand Down
2 changes: 1 addition & 1 deletion js/xpconnect/tests/chrome/bug503926.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=503926
var gWindowUtils = window.windowUtils;
var passed = false;
// eslint-disable-next-line mozilla/use-chromeutils-generateqi
var obj = { QueryInterface: function() { passed = true; } }
var obj = { QueryInterface() { passed = true; } }
gWindowUtils.xpconnectArgument(obj);
var isDialog = location.hash != '#iframe';
var outer = XPCNativeWrapper.unwrap(isDialog ? window.arguments[0] : parent);
Expand Down
8 changes: 5 additions & 3 deletions js/xpconnect/tests/chrome/file_expandosharing.jsm
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
var EXPORTED_SYMBOLS = ['checkFromJSM'];
var EXPORTED_SYMBOLS = ["checkFromJSM"];

function checkFromJSM(target, is_op) {
is_op(target.numProp, 42, "Number expando works");
is_op(target.strProp, "foo", "String expando works");
// If is_op is todo_is, target.objProp will be undefined.
try {
is_op(target.objProp.bar, "baz", "Object expando works");
} catch(e) { is_op(0, 1, "No object expando"); }
}
} catch (e) {
is_op(0, 1, "No object expando");
}
}
3 changes: 1 addition & 2 deletions js/xpconnect/tests/chrome/outoflinexulscript.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Some unicode characters that must be decoded:
// ………………………………………………………………………………………………………………………………
function outoflinefunction() {
return 42;
return 42;
}

2 changes: 1 addition & 1 deletion js/xpconnect/tests/chrome/test_APIExposer.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=634156

function genPropDesc(value) {
return { enumerable: true, configurable: true, writable: true,
value: value };
value };
}
const props = {
'getProp': genPropDesc(function() { ok(true, "called prop that shadowed a getter"); }),
Expand Down
2 changes: 1 addition & 1 deletion js/xpconnect/tests/chrome/test_bug1041626.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1041626
xrayOwnProperties = Object.getOwnPropertyNames(window[0].document);

realOwnProperties = Object.getOwnPropertyNames(window[0].wrappedJSObject.document);
ok(realOwnProperties.length > 0);
ok(!!realOwnProperties.length);

is(xrayOwnProperties.sort().toSource(), realOwnProperties.sort().toSource(),
"Xray enumerates document properties properly");
Expand Down
2 changes: 1 addition & 1 deletion js/xpconnect/tests/chrome/test_bug1074863.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<script type="application/javascript">

/** Test for Bug 1074863 **/
var sb = new Cu.Sandbox('http://www.example.com');
var sb = new Cu.Sandbox("https://www.example.com");
sb.namedCtor = Image;
ok(true, "Didn't assert");

Expand Down
2 changes: 1 addition & 1 deletion js/xpconnect/tests/chrome/test_bug1124898.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
var w = window.browsingContext.topChromeWindow.open("about:blank", "w", "chrome");
is(w.eval('typeof getAttention'), 'function', 'getAttention exists on regular chrome window');
is(w.eval('typeof messageManager'), 'object', 'messageManager exists on regular chrome window');
var contentURL = "http://example.org/tests/js/xpconnect/tests/mochitest/file_empty.html";
var contentURL = "https://example.org/tests/js/xpconnect/tests/mochitest/file_empty.html";
w.location = contentURL;
tryWindow();

Expand Down
2 changes: 1 addition & 1 deletion js/xpconnect/tests/chrome/test_bug503926.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=503926
// Try with a chrome object.
var passed = false;
// eslint-disable-next-line mozilla/use-chromeutils-generateqi
var obj = { QueryInterface: function() { passed = true; } };
var obj = { QueryInterface() { passed = true; } };
gWindowUtils.xpconnectArgument(obj);
ok(passed, "trusted QIs should be called");

Expand Down
4 changes: 2 additions & 2 deletions js/xpconnect/tests/chrome/test_bug596580.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@
await SpecialPowers.pushPrefEnv({"set": [["security.allow_eval_with_system_principal",
true]]});
Test = {
include: function(p) {
include(p) {
var sawError = false;
try {
Cc["@mozilla.org/moz/jssubscript-loader;1"].
getService(Ci["mozIJSSubScriptLoader"]).
getService(Ci.mozIJSSubScriptLoader).
loadSubScript(p);
} catch (e) {
sawError = true;
Expand Down
12 changes: 6 additions & 6 deletions js/xpconnect/tests/chrome/test_bug658909.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -31,36 +31,36 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=658909
}

var testFunctions = {
testDocumentElement: function(a, b, name) {
testDocumentElement(a, b, name) {
var getter = Object.prototype.__lookupGetter__.call(a.document, 'documentElement');
is(getter.call(b.document), b.document.documentElement, msg(a, b, name));
},

testInvalidCall: function(a, b, name) {
testInvalidCall(a, b, name) {
var getter = Object.prototype.__lookupGetter__.call(a.document, 'documentElement');
var threw = false;
try { getter.call(b.document.body); } catch (e) { threw = true; };
ok(threw, msg(a, b, name));
},

testStatus: function(a, b, name) {
testStatus(a, b, name) {
var setter = Object.prototype.__lookupSetter__.call(a, 'status');
is(b.status, "", "Empty status");
setter.call(b, "foopy");
is(b.status, "foopy", msg(a, b, name));
b.status = "";
},

testCreateElement: function(a, b, name) {
testCreateElement(a, b, name) {
is(a.document.createElement.call(b.document, 'div').ownerDocument, b.document, msg(a, b, name));
},

testWindowName: function(a, b, name) {
testWindowName(a, b, name) {
var getter = Object.prototype.__lookupGetter__.call(a, 'name');
is(getter.call(b), b.name, msg(a, b, name));
},

testCanvas: function(a, b, name) {
testCanvas(a, b, name) {
var canvasA = a.document.createElement('canvas');
var canvasB = b.document.createElement('canvas');
var contextA = canvasA.getContext('2d');
Expand Down
2 changes: 1 addition & 1 deletion js/xpconnect/tests/chrome/test_bug706301.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=706301

// Perform the operation.
Object.getOwnPropertyDescriptor(nodelist, 'length');
return nodelist['length'] == 0;
return !nodelist.length;
}

function finishTestInChrome() {
Expand Down
4 changes: 2 additions & 2 deletions js/xpconnect/tests/chrome/test_bug720619.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=720619
<script type="application/javascript"><![CDATA[
/** Test for Bug 720619 **/
var obj = {
valueOf: function () {
valueOf () {
return 42;
},
toString: function () {
toString () {
return 'str';
}
};
Expand Down
2 changes: 1 addition & 1 deletion js/xpconnect/tests/chrome/test_bug732665.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ add_task(async () => {
return inner();
}

var contentSb = new Cu.Sandbox('http://www.example.com');
var contentSb = new Cu.Sandbox("https://www.example.com");
var chromeSb = new Cu.Sandbox(window);
chromeSb.ok = contentSb.ok = ok;
Cu.evalInSandbox(nearNativeStackLimit.toSource(), chromeSb);
Expand Down
18 changes: 13 additions & 5 deletions js/xpconnect/tests/chrome/test_bug732665_meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ var top = bottom;
function nearNativeStackLimit() {
function inner() {
try {
with ({}) { // keep things predictable -- stay in the interpreter
with ({}) {
// keep things predictable -- stay in the interpreter
top = stackPointerInfo();
var stepsFromLimit = eval("inner()"); // Use eval to force a number of native stackframes to be created.
}
return stepsFromLimit + 1;
} catch(e) {
} catch (e) {
// It would be nice to check here that the exception is actually an
// over-recursion here. But doing so would require toString()ing the
// exception, which we may not have the stack space to do.
Expand All @@ -21,6 +22,13 @@ function nearNativeStackLimit() {

var nbFrames = nearNativeStackLimit();
var frameSize = bottom - top;
print("Max stack size:", frameSize, "bytes",
"\nMaximum number of frames:", nbFrames,
"\nAverage frame size:", Math.ceil(frameSize / nbFrames), "bytes");
print(
"Max stack size:",
frameSize,
"bytes",
"\nMaximum number of frames:",
nbFrames,
"\nAverage frame size:",
Math.ceil(frameSize / nbFrames),
"bytes"
);
2 changes: 1 addition & 1 deletion js/xpconnect/tests/chrome/test_bug760076.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=760076
}

// Set up the sandbox.
var sb = new Cu.Sandbox('http://www.example.com');
var sb = new Cu.Sandbox("https://www.example.com");

// Import the functions it needs.
sb.ok = ok;
Expand Down
2 changes: 1 addition & 1 deletion js/xpconnect/tests/chrome/test_bug771429.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=771429
function test(freshCompartment) {
var s = new Cu.Sandbox(window, {
sandboxPrototype: window,
freshCompartment: freshCompartment,
freshCompartment,
});
try {
is(Cu.evalInSandbox('g()', s), window,
Expand Down
8 changes: 1 addition & 7 deletions js/xpconnect/tests/chrome/test_bug795275.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=795275
}
var gListener = {
observe: onWarning,
QueryInterface: function (iid) {
if (!iid.equals(Ci.nsIConsoleListener) &&
!iid.equals(Ci.nsISupports)) {
throw Cr.NS_ERROR_NO_INTERFACE;
}
return this;
}
QueryInterface: ChromeUtils.generateQI(["nsIConsoleListener"])
};
var gConsoleService = Cc["@mozilla.org/consoleservice;1"]
.getService(Ci.nsIConsoleService);
Expand Down
7 changes: 3 additions & 4 deletions js/xpconnect/tests/chrome/test_bug799348.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,18 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=799348
gCalledOnload = false;
var myObserver = {
QueryInterface: ChromeUtils.generateQI(["nsIObserver"]),
observe: function(win, topic, data) {
observe(win, topic, data) {
if (topic == "domwindowopened") {
ok(!gCalledOnload, "domwindowopened notification fired before onload");
win.addEventListener("load", function(evt) {
gCalledOnload = true;
win.close();
}, false);
});
} else if (topic == "domwindowclosed") {
ok(gCalledOnload, "should have called onload");
Services.ww.unregisterNotification(myObserver);
SimpleTest.finish();
}
else {
} else {
ok(false, "unknown topic");
}
}
Expand Down
9 changes: 1 addition & 8 deletions js/xpconnect/tests/chrome/test_bug895340.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=895340
.getService(Ci.nsIConsoleService);

let listener = {
QueryInterface: function(iid) {
if (!iid.equals(Ci.nsIConsoleListener) &&
!iid.equals(Ci.nsISupports))
{
throw Cr.NS_ERROR_NO_INTERFACE;
}
return this;
}
QueryInterface: ChromeUtils.generateQI(["nsIConsoleListener"])
};

listener.observe = function(aMessage) {
Expand Down
10 changes: 5 additions & 5 deletions js/xpconnect/tests/chrome/test_cloneInto.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,10 @@
if (Array.isArray(a))
return 'array';

if (a instanceof File)
if (File.isInstance(a))
return 'file';

if (a instanceof Blob)
if (Blob.isInstance(a))
return 'blob';

if (TypedArrayThings.includes(a.constructor.name))
Expand Down Expand Up @@ -152,7 +152,7 @@
cloneAndTest(tests[i]);
}

checkThrows(function() { Cu.cloneInto({ a: function() {} }, sandbox); },
checkThrows(function() { Cu.cloneInto({ a() {} }, sandbox); },
'Function should not be cloned by default');

checkThrows(function() { Cu.cloneInto({ a: document }, sandbox); },
Expand Down Expand Up @@ -181,11 +181,11 @@
'wrapReflectors may not wrap cross-origin reflectors', /unsupported value type/);


var test = { a: function() { return 42; } };
var test = { a() { return 42; } };
cloneAndTestWithFunctions(test);

// Check that inputs are properly passed through cloned functions:
test = { a: function(obj) { return obj; } };
test = { a(obj) { return obj; } };
var clonedTest = Cu.cloneInto(test, sandbox, {cloneFunctions: true});
var testInput = {};
is(clonedTest.a(testInput), testInput, "Objects should be identical");
Expand Down
2 changes: 1 addition & 1 deletion js/xpconnect/tests/chrome/test_exposeInDerived.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=804630
<![CDATA[
/** Test to make sure that COWed objects can't expose properties from their prototypes. **/
// Set up the sandbox.
var sb = new Cu.Sandbox('http://www.example.com');
var sb = new Cu.Sandbox("https://www.example.com");
sb.ok = ok;
sb.is = is;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=673468
sandbox.wrapper = null;
sandbox.value = null;

live_dom.xyzabc = {wrappee: wrappee, m: map, sb: sandbox};
live_dom.xyzabc = {wrappee, m: map, sb: sandbox};

let key = ChromeUtils.nondeterministicGetWeakMapKeys(map)[0];
let value = map.get(key);
Expand Down
2 changes: 1 addition & 1 deletion js/xpconnect/tests/chrome/test_windowProxyDeadWrapper.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
ok(!checkDead(), "WindowProxy shouldn't be dead yet");

// Load a content page in the chrome frame.
w.location = "http://example.org/tests/js/xpconnect/tests/mochitest/file_empty.html";
w.location = "https://example.org/tests/js/xpconnect/tests/mochitest/file_empty.html";
tryWindow();

function tryWindow() {
Expand Down
Loading

0 comments on commit d8c43d0

Please sign in to comment.