Bug 1793227, part 3 - Automatic fixes for js/xpconnect/tests/chrome. 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
This commit is contained in:
Andrew McCreight 2022-10-10 22:22:00 +00:00
parent a2486eeeb0
commit d8c43d0ea1
26 changed files with 98 additions and 96 deletions

View file

@ -138,12 +138,17 @@ intl/l10n/
# Exclude everything but self-hosted JS # Exclude everything but self-hosted JS
js/examples/ js/examples/
js/public/ js/public/
js/xpconnect/
js/src/devtools/ js/src/devtools/
js/src/jit-test/ js/src/jit-test/
js/src/tests/ js/src/tests/
js/src/Y.js 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 # Fuzzing code for testing only, targeting the JS shell
js/src/fuzz-tests/ js/src/fuzz-tests/

View file

@ -18,7 +18,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=503926
var gWindowUtils = window.windowUtils; var gWindowUtils = window.windowUtils;
var passed = false; var passed = false;
// eslint-disable-next-line mozilla/use-chromeutils-generateqi // eslint-disable-next-line mozilla/use-chromeutils-generateqi
var obj = { QueryInterface: function() { passed = true; } } var obj = { QueryInterface() { passed = true; } }
gWindowUtils.xpconnectArgument(obj); gWindowUtils.xpconnectArgument(obj);
var isDialog = location.hash != '#iframe'; var isDialog = location.hash != '#iframe';
var outer = XPCNativeWrapper.unwrap(isDialog ? window.arguments[0] : parent); var outer = XPCNativeWrapper.unwrap(isDialog ? window.arguments[0] : parent);

View file

@ -1,4 +1,4 @@
var EXPORTED_SYMBOLS = ['checkFromJSM']; var EXPORTED_SYMBOLS = ["checkFromJSM"];
function checkFromJSM(target, is_op) { function checkFromJSM(target, is_op) {
is_op(target.numProp, 42, "Number expando works"); is_op(target.numProp, 42, "Number expando works");
@ -6,5 +6,7 @@ function checkFromJSM(target, is_op) {
// If is_op is todo_is, target.objProp will be undefined. // If is_op is todo_is, target.objProp will be undefined.
try { try {
is_op(target.objProp.bar, "baz", "Object expando works"); 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");
}
}

View file

@ -1,6 +1,5 @@
// Some unicode characters that must be decoded: // Some unicode characters that must be decoded:
// ……………………………………………………………………………………………………………………………… // ………………………………………………………………………………………………………………………………
function outoflinefunction() { function outoflinefunction() {
return 42; return 42;
} }

View file

@ -29,7 +29,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=634156
function genPropDesc(value) { function genPropDesc(value) {
return { enumerable: true, configurable: true, writable: true, return { enumerable: true, configurable: true, writable: true,
value: value }; value };
} }
const props = { const props = {
'getProp': genPropDesc(function() { ok(true, "called prop that shadowed a getter"); }), 'getProp': genPropDesc(function() { ok(true, "called prop that shadowed a getter"); }),

View file

@ -42,7 +42,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1041626
xrayOwnProperties = Object.getOwnPropertyNames(window[0].document); xrayOwnProperties = Object.getOwnPropertyNames(window[0].document);
realOwnProperties = Object.getOwnPropertyNames(window[0].wrappedJSObject.document); realOwnProperties = Object.getOwnPropertyNames(window[0].wrappedJSObject.document);
ok(realOwnProperties.length > 0); ok(!!realOwnProperties.length);
is(xrayOwnProperties.sort().toSource(), realOwnProperties.sort().toSource(), is(xrayOwnProperties.sort().toSource(), realOwnProperties.sort().toSource(),
"Xray enumerates document properties properly"); "Xray enumerates document properties properly");

View file

@ -12,7 +12,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1074863
<script type="application/javascript"> <script type="application/javascript">
/** Test for Bug 1074863 **/ /** 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; sb.namedCtor = Image;
ok(true, "Didn't assert"); ok(true, "Didn't assert");

View file

@ -21,7 +21,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1124898
var w = window.browsingContext.topChromeWindow.open("about:blank", "w", "chrome"); 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 getAttention'), 'function', 'getAttention exists on regular chrome window');
is(w.eval('typeof messageManager'), 'object', 'messageManager 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; w.location = contentURL;
tryWindow(); tryWindow();

View file

@ -36,7 +36,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=503926
// Try with a chrome object. // Try with a chrome object.
var passed = false; var passed = false;
// eslint-disable-next-line mozilla/use-chromeutils-generateqi // eslint-disable-next-line mozilla/use-chromeutils-generateqi
var obj = { QueryInterface: function() { passed = true; } }; var obj = { QueryInterface() { passed = true; } };
gWindowUtils.xpconnectArgument(obj); gWindowUtils.xpconnectArgument(obj);
ok(passed, "trusted QIs should be called"); ok(passed, "trusted QIs should be called");

View file

@ -26,11 +26,11 @@
await SpecialPowers.pushPrefEnv({"set": [["security.allow_eval_with_system_principal", await SpecialPowers.pushPrefEnv({"set": [["security.allow_eval_with_system_principal",
true]]}); true]]});
Test = { Test = {
include: function(p) { include(p) {
var sawError = false; var sawError = false;
try { try {
Cc["@mozilla.org/moz/jssubscript-loader;1"]. Cc["@mozilla.org/moz/jssubscript-loader;1"].
getService(Ci["mozIJSSubScriptLoader"]). getService(Ci.mozIJSSubScriptLoader).
loadSubScript(p); loadSubScript(p);
} catch (e) { } catch (e) {
sawError = true; sawError = true;

View file

@ -31,19 +31,19 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=658909
} }
var testFunctions = { var testFunctions = {
testDocumentElement: function(a, b, name) { testDocumentElement(a, b, name) {
var getter = Object.prototype.__lookupGetter__.call(a.document, 'documentElement'); var getter = Object.prototype.__lookupGetter__.call(a.document, 'documentElement');
is(getter.call(b.document), b.document.documentElement, msg(a, b, name)); 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 getter = Object.prototype.__lookupGetter__.call(a.document, 'documentElement');
var threw = false; var threw = false;
try { getter.call(b.document.body); } catch (e) { threw = true; }; try { getter.call(b.document.body); } catch (e) { threw = true; };
ok(threw, msg(a, b, name)); ok(threw, msg(a, b, name));
}, },
testStatus: function(a, b, name) { testStatus(a, b, name) {
var setter = Object.prototype.__lookupSetter__.call(a, 'status'); var setter = Object.prototype.__lookupSetter__.call(a, 'status');
is(b.status, "", "Empty status"); is(b.status, "", "Empty status");
setter.call(b, "foopy"); setter.call(b, "foopy");
@ -51,16 +51,16 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=658909
b.status = ""; 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)); 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'); var getter = Object.prototype.__lookupGetter__.call(a, 'name');
is(getter.call(b), b.name, msg(a, b, 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 canvasA = a.document.createElement('canvas');
var canvasB = b.document.createElement('canvas'); var canvasB = b.document.createElement('canvas');
var contextA = canvasA.getContext('2d'); var contextA = canvasA.getContext('2d');

View file

@ -30,7 +30,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=706301
// Perform the operation. // Perform the operation.
Object.getOwnPropertyDescriptor(nodelist, 'length'); Object.getOwnPropertyDescriptor(nodelist, 'length');
return nodelist['length'] == 0; return !nodelist.length;
} }
function finishTestInChrome() { function finishTestInChrome() {

View file

@ -18,10 +18,10 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=720619
<script type="application/javascript"><![CDATA[ <script type="application/javascript"><![CDATA[
/** Test for Bug 720619 **/ /** Test for Bug 720619 **/
var obj = { var obj = {
valueOf: function () { valueOf () {
return 42; return 42;
}, },
toString: function () { toString () {
return 'str'; return 'str';
} }
}; };

View file

@ -51,7 +51,7 @@ add_task(async () => {
return inner(); 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); var chromeSb = new Cu.Sandbox(window);
chromeSb.ok = contentSb.ok = ok; chromeSb.ok = contentSb.ok = ok;
Cu.evalInSandbox(nearNativeStackLimit.toSource(), chromeSb); Cu.evalInSandbox(nearNativeStackLimit.toSource(), chromeSb);

View file

@ -4,12 +4,13 @@ var top = bottom;
function nearNativeStackLimit() { function nearNativeStackLimit() {
function inner() { function inner() {
try { try {
with ({}) { // keep things predictable -- stay in the interpreter with ({}) {
// keep things predictable -- stay in the interpreter
top = stackPointerInfo(); top = stackPointerInfo();
var stepsFromLimit = eval("inner()"); // Use eval to force a number of native stackframes to be created. var stepsFromLimit = eval("inner()"); // Use eval to force a number of native stackframes to be created.
} }
return stepsFromLimit + 1; return stepsFromLimit + 1;
} catch(e) { } catch (e) {
// It would be nice to check here that the exception is actually an // It would be nice to check here that the exception is actually an
// over-recursion here. But doing so would require toString()ing the // over-recursion here. But doing so would require toString()ing the
// exception, which we may not have the stack space to do. // exception, which we may not have the stack space to do.
@ -21,6 +22,13 @@ function nearNativeStackLimit() {
var nbFrames = nearNativeStackLimit(); var nbFrames = nearNativeStackLimit();
var frameSize = bottom - top; var frameSize = bottom - top;
print("Max stack size:", frameSize, "bytes", print(
"\nMaximum number of frames:", nbFrames, "Max stack size:",
"\nAverage frame size:", Math.ceil(frameSize / nbFrames), "bytes"); frameSize,
"bytes",
"\nMaximum number of frames:",
nbFrames,
"\nAverage frame size:",
Math.ceil(frameSize / nbFrames),
"bytes"
);

View file

@ -32,7 +32,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=760076
} }
// Set up the sandbox. // 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. // Import the functions it needs.
sb.ok = ok; sb.ok = ok;

View file

@ -27,7 +27,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=771429
function test(freshCompartment) { function test(freshCompartment) {
var s = new Cu.Sandbox(window, { var s = new Cu.Sandbox(window, {
sandboxPrototype: window, sandboxPrototype: window,
freshCompartment: freshCompartment, freshCompartment,
}); });
try { try {
is(Cu.evalInSandbox('g()', s), window, is(Cu.evalInSandbox('g()', s), window,

View file

@ -40,13 +40,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=795275
} }
var gListener = { var gListener = {
observe: onWarning, observe: onWarning,
QueryInterface: function (iid) { QueryInterface: ChromeUtils.generateQI(["nsIConsoleListener"])
if (!iid.equals(Ci.nsIConsoleListener) &&
!iid.equals(Ci.nsISupports)) {
throw Cr.NS_ERROR_NO_INTERFACE;
}
return this;
}
}; };
var gConsoleService = Cc["@mozilla.org/consoleservice;1"] var gConsoleService = Cc["@mozilla.org/consoleservice;1"]
.getService(Ci.nsIConsoleService); .getService(Ci.nsIConsoleService);

View file

@ -22,19 +22,18 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=799348
gCalledOnload = false; gCalledOnload = false;
var myObserver = { var myObserver = {
QueryInterface: ChromeUtils.generateQI(["nsIObserver"]), QueryInterface: ChromeUtils.generateQI(["nsIObserver"]),
observe: function(win, topic, data) { observe(win, topic, data) {
if (topic == "domwindowopened") { if (topic == "domwindowopened") {
ok(!gCalledOnload, "domwindowopened notification fired before onload"); ok(!gCalledOnload, "domwindowopened notification fired before onload");
win.addEventListener("load", function(evt) { win.addEventListener("load", function(evt) {
gCalledOnload = true; gCalledOnload = true;
win.close(); win.close();
}, false); });
} else if (topic == "domwindowclosed") { } else if (topic == "domwindowclosed") {
ok(gCalledOnload, "should have called onload"); ok(gCalledOnload, "should have called onload");
Services.ww.unregisterNotification(myObserver); Services.ww.unregisterNotification(myObserver);
SimpleTest.finish(); SimpleTest.finish();
} } else {
else {
ok(false, "unknown topic"); ok(false, "unknown topic");
} }
} }

View file

@ -27,14 +27,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=895340
.getService(Ci.nsIConsoleService); .getService(Ci.nsIConsoleService);
let listener = { let listener = {
QueryInterface: function(iid) { QueryInterface: ChromeUtils.generateQI(["nsIConsoleListener"])
if (!iid.equals(Ci.nsIConsoleListener) &&
!iid.equals(Ci.nsISupports))
{
throw Cr.NS_ERROR_NO_INTERFACE;
}
return this;
}
}; };
listener.observe = function(aMessage) { listener.observe = function(aMessage) {

View file

@ -45,10 +45,10 @@
if (Array.isArray(a)) if (Array.isArray(a))
return 'array'; return 'array';
if (a instanceof File) if (File.isInstance(a))
return 'file'; return 'file';
if (a instanceof Blob) if (Blob.isInstance(a))
return 'blob'; return 'blob';
if (TypedArrayThings.includes(a.constructor.name)) if (TypedArrayThings.includes(a.constructor.name))
@ -152,7 +152,7 @@
cloneAndTest(tests[i]); cloneAndTest(tests[i]);
} }
checkThrows(function() { Cu.cloneInto({ a: function() {} }, sandbox); }, checkThrows(function() { Cu.cloneInto({ a() {} }, sandbox); },
'Function should not be cloned by default'); 'Function should not be cloned by default');
checkThrows(function() { Cu.cloneInto({ a: document }, sandbox); }, checkThrows(function() { Cu.cloneInto({ a: document }, sandbox); },
@ -181,11 +181,11 @@
'wrapReflectors may not wrap cross-origin reflectors', /unsupported value type/); 'wrapReflectors may not wrap cross-origin reflectors', /unsupported value type/);
var test = { a: function() { return 42; } }; var test = { a() { return 42; } };
cloneAndTestWithFunctions(test); cloneAndTestWithFunctions(test);
// Check that inputs are properly passed through cloned functions: // 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 clonedTest = Cu.cloneInto(test, sandbox, {cloneFunctions: true});
var testInput = {}; var testInput = {};
is(clonedTest.a(testInput), testInput, "Objects should be identical"); is(clonedTest.a(testInput), testInput, "Objects should be identical");

View file

@ -19,7 +19,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=804630
<![CDATA[ <![CDATA[
/** Test to make sure that COWed objects can't expose properties from their prototypes. **/ /** Test to make sure that COWed objects can't expose properties from their prototypes. **/
// Set up the sandbox. // 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.ok = ok;
sb.is = is; sb.is = is;

View file

@ -48,7 +48,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=673468
sandbox.wrapper = null; sandbox.wrapper = null;
sandbox.value = 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 key = ChromeUtils.nondeterministicGetWeakMapKeys(map)[0];
let value = map.get(key); let value = map.get(key);

View file

@ -33,7 +33,7 @@ async function go() {
ok(!checkDead(), "WindowProxy shouldn't be dead yet"); ok(!checkDead(), "WindowProxy shouldn't be dead yet");
// Load a content page in the chrome frame. // 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(); tryWindow();
function tryWindow() { function tryWindow() {

View file

@ -77,7 +77,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=933681
is(Cu.unwaiveXrays(Cu.waiveXrays(new iwin[c](...args)).constructor), iwin[c], is(Cu.unwaiveXrays(Cu.waiveXrays(new iwin[c](...args)).constructor), iwin[c],
"constructor property is set up right: " + c); "constructor property is set up right: " + c);
let expectedProto = Cu.isOpaqueWrapper(new iwin[c](...args)) ? let expectedProto = Cu.isOpaqueWrapper(new iwin[c](...args)) ?
iwin['Object'].prototype : iwin[c].prototype; iwin.Object.prototype : iwin[c].prototype;
is(Object.getPrototypeOf(new iwin[c](...args)), expectedProto, is(Object.getPrototypeOf(new iwin[c](...args)), expectedProto,
"prototype is correct: " + c); "prototype is correct: " + c);
is(global(new iwin[c](...args)), iwin, "Got the right global: " + c); is(global(new iwin[c](...args)), iwin, "Got the right global: " + c);
@ -147,7 +147,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=933681
is(Cu.unwaiveXrays(Cu.waiveXrays(new iwin.AggregateError(...args)).constructor), iwin.AggregateError, is(Cu.unwaiveXrays(Cu.waiveXrays(new iwin.AggregateError(...args)).constructor), iwin.AggregateError,
"AggregateError constructor property is set up right"); "AggregateError constructor property is set up right");
let expectedProto = Cu.isOpaqueWrapper(new iwin.AggregateError(...args)) ? let expectedProto = Cu.isOpaqueWrapper(new iwin.AggregateError(...args)) ?
iwin['Object'].prototype : iwin.AggregateError.prototype; iwin.Object.prototype : iwin.AggregateError.prototype;
is(Object.getPrototypeOf(new iwin.AggregateError(...args)), expectedProto, is(Object.getPrototypeOf(new iwin.AggregateError(...args)), expectedProto,
"AggregateError prototype is correct"); "AggregateError prototype is correct");
is(global(new iwin.AggregateError(...args)), iwin, "Got the right global for AggregateError"); is(global(new iwin.AggregateError(...args)), iwin, "Got the right global for AggregateError");
@ -203,7 +203,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=933681
// Some props live on all constructors // Some props live on all constructors
return arr.concat(["prototype", "length", "name"]); return arr.concat(["prototype", "length", "name"]);
} }
gPrototypeProperties['Date'] = gPrototypeProperties.Date =
["getTime", "getTimezoneOffset", "getYear", "getFullYear", "getUTCFullYear", ["getTime", "getTimezoneOffset", "getYear", "getFullYear", "getUTCFullYear",
"getMonth", "getUTCMonth", "getDate", "getUTCDate", "getDay", "getUTCDay", "getMonth", "getUTCMonth", "getDate", "getUTCDate", "getDay", "getUTCDay",
"getHours", "getUTCHours", "getMinutes", "getUTCMinutes", "getSeconds", "getHours", "getUTCHours", "getMinutes", "getUTCMinutes", "getSeconds",
@ -215,36 +215,36 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=933681
"toLocaleDateString", "toLocaleTimeString", "toDateString", "toTimeString", "toLocaleDateString", "toLocaleTimeString", "toDateString", "toTimeString",
"toISOString", "toJSON", "toSource", "toString", "valueOf", "constructor", "toISOString", "toJSON", "toSource", "toString", "valueOf", "constructor",
"toGMTString", Symbol.toPrimitive]; "toGMTString", Symbol.toPrimitive];
gConstructorProperties['Date'] = constructorProps(["UTC", "parse", "now"]); gConstructorProperties.Date = constructorProps(["UTC", "parse", "now"]);
gPrototypeProperties['Object'] = gPrototypeProperties.Object =
["constructor", "toSource", "toString", "toLocaleString", "valueOf", ["constructor", "toSource", "toString", "toLocaleString", "valueOf",
"hasOwnProperty", "isPrototypeOf", "propertyIsEnumerable", "hasOwnProperty", "isPrototypeOf", "propertyIsEnumerable",
"__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__", "__defineGetter__", "__defineSetter__", "__lookupGetter__", "__lookupSetter__",
"__proto__"]; "__proto__"];
gConstructorProperties['Object'] = gConstructorProperties.Object =
constructorProps(["setPrototypeOf", "getOwnPropertyDescriptor", "getOwnPropertyDescriptors", constructorProps(["setPrototypeOf", "getOwnPropertyDescriptor", "getOwnPropertyDescriptors",
"keys", "is", "defineProperty", "defineProperties", "create", "keys", "is", "defineProperty", "defineProperties", "create",
"getOwnPropertyNames", "getOwnPropertySymbols", "getOwnPropertyNames", "getOwnPropertySymbols",
"preventExtensions", "freeze", "fromEntries", "isFrozen", "seal", "preventExtensions", "freeze", "fromEntries", "isFrozen", "seal",
"isSealed", "assign", "getPrototypeOf", "values", "isSealed", "assign", "getPrototypeOf", "values",
"entries", "isExtensible", "hasOwn"]); "entries", "isExtensible", "hasOwn"]);
gPrototypeProperties['Array'] = gPrototypeProperties.Array =
["length", "toSource", "toString", "toLocaleString", "join", "reverse", "sort", "push", ["length", "toSource", "toString", "toLocaleString", "join", "reverse", "sort", "push",
"pop", "shift", "unshift", "splice", "concat", "slice", "lastIndexOf", "indexOf", "pop", "shift", "unshift", "splice", "concat", "slice", "lastIndexOf", "indexOf",
"includes", "forEach", "map", "reduce", "reduceRight", "filter", "some", "every", "find", "includes", "forEach", "map", "reduce", "reduceRight", "filter", "some", "every", "find",
"findIndex", "copyWithin", "fill", Symbol.iterator, Symbol.unscopables, "entries", "keys", "findIndex", "copyWithin", "fill", Symbol.iterator, Symbol.unscopables, "entries", "keys",
"values", "constructor", "flat", "flatMap", "at", "findLast", "findLastIndex"]; "values", "constructor", "flat", "flatMap", "at", "findLast", "findLastIndex"];
if (isNightlyBuild) { if (isNightlyBuild) {
gPrototypeProperties['Array'].push("group"); gPrototypeProperties.Array.push("group");
gPrototypeProperties['Array'].push("groupToMap"); gPrototypeProperties.Array.push("groupToMap");
} }
gConstructorProperties['Array'] = gConstructorProperties.Array =
constructorProps(["isArray", "from", "of", Symbol.species]); constructorProps(["isArray", "from", "of", Symbol.species]);
for (var c of typedArrayClasses) { for (var c of typedArrayClasses) {
gPrototypeProperties[c] = ["constructor", "BYTES_PER_ELEMENT"]; gPrototypeProperties[c] = ["constructor", "BYTES_PER_ELEMENT"];
gConstructorProperties[c] = constructorProps(["BYTES_PER_ELEMENT"]); gConstructorProperties[c] = constructorProps(["BYTES_PER_ELEMENT"]);
} }
gPrototypeProperties['TypedArray'] = gPrototypeProperties.TypedArray =
["length", "buffer", "byteLength", "byteOffset", Symbol.iterator, "subarray", ["length", "buffer", "byteLength", "byteOffset", Symbol.iterator, "subarray",
"set", "copyWithin", "find", "findIndex", "forEach","indexOf", "lastIndexOf", "includes", "set", "copyWithin", "find", "findIndex", "forEach","indexOf", "lastIndexOf", "includes",
"reverse", "join", "every", "some", "reduce", "reduceRight", "entries", "keys", "values", "reverse", "join", "every", "some", "reduce", "reduceRight", "entries", "keys", "values",
@ -256,68 +256,68 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=933681
gConstructorProperties[c] = constructorProps([]); gConstructorProperties[c] = constructorProps([]);
} }
// toString and toSource only live on the parent proto (Error.prototype). // toString and toSource only live on the parent proto (Error.prototype).
gPrototypeProperties['Error'].push('toString'); gPrototypeProperties.Error.push('toString');
gPrototypeProperties['Error'].push('toSource'); gPrototypeProperties.Error.push('toSource');
gPrototypeProperties['Function'] = gPrototypeProperties.Function =
["constructor", "toSource", "toString", "apply", "call", "bind", ["constructor", "toSource", "toString", "apply", "call", "bind",
"length", "name", "arguments", "caller", Symbol.hasInstance]; "length", "name", "arguments", "caller", Symbol.hasInstance];
gConstructorProperties['Function'] = constructorProps([]) gConstructorProperties.Function = constructorProps([])
gPrototypeProperties['RegExp'] = gPrototypeProperties.RegExp =
["constructor", "toSource", "toString", "compile", "exec", "test", ["constructor", "toSource", "toString", "compile", "exec", "test",
Symbol.match, Symbol.matchAll, Symbol.replace, Symbol.search, Symbol.split, Symbol.match, Symbol.matchAll, Symbol.replace, Symbol.search, Symbol.split,
"flags", "dotAll", "global", "hasIndices", "ignoreCase", "multiline", "source", "sticky", "flags", "dotAll", "global", "hasIndices", "ignoreCase", "multiline", "source", "sticky",
"unicode"]; "unicode"];
gConstructorProperties['RegExp'] = gConstructorProperties.RegExp =
constructorProps(["input", "lastMatch", "lastParen", constructorProps(["input", "lastMatch", "lastParen",
"leftContext", "rightContext", "$1", "$2", "$3", "$4", "leftContext", "rightContext", "$1", "$2", "$3", "$4",
"$5", "$6", "$7", "$8", "$9", "$_", "$&", "$+", "$5", "$6", "$7", "$8", "$9", "$_", "$&", "$+",
"$`", "$'", Symbol.species]) "$`", "$'", Symbol.species])
gPrototypeProperties['Promise'] = gPrototypeProperties.Promise =
["constructor", "catch", "then", "finally", Symbol.toStringTag]; ["constructor", "catch", "then", "finally", Symbol.toStringTag];
gConstructorProperties['Promise'] = gConstructorProperties.Promise =
constructorProps(["resolve", "reject", "all", "allSettled", "any", "race", Symbol.species]); constructorProps(["resolve", "reject", "all", "allSettled", "any", "race", Symbol.species]);
gPrototypeProperties['ArrayBuffer'] = gPrototypeProperties.ArrayBuffer =
["constructor", "byteLength", "slice", Symbol.toStringTag]; ["constructor", "byteLength", "slice", Symbol.toStringTag];
gConstructorProperties['ArrayBuffer'] = gConstructorProperties.ArrayBuffer =
constructorProps(["isView", Symbol.species]); constructorProps(["isView", Symbol.species]);
gPrototypeProperties['SharedArrayBuffer'] = ["constructor", "slice", "byteLength", Symbol.toStringTag]; gPrototypeProperties.SharedArrayBuffer = ["constructor", "slice", "byteLength", Symbol.toStringTag];
gConstructorProperties['SharedArrayBuffer'] = constructorProps([Symbol.species]); gConstructorProperties.SharedArrayBuffer = constructorProps([Symbol.species]);
gPrototypeProperties['Map'] = gPrototypeProperties.Map =
["constructor", "size", Symbol.toStringTag, "get", "has", "set", "delete", ["constructor", "size", Symbol.toStringTag, "get", "has", "set", "delete",
"keys", "values", "clear", "forEach", "entries", Symbol.iterator]; "keys", "values", "clear", "forEach", "entries", Symbol.iterator];
gConstructorProperties['Map'] = gConstructorProperties.Map =
constructorProps([Symbol.species]); constructorProps([Symbol.species]);
gPrototypeProperties['Set'] = gPrototypeProperties.Set =
["constructor", "size", Symbol.toStringTag, "has", "add", "delete", ["constructor", "size", Symbol.toStringTag, "has", "add", "delete",
"keys", "values", "clear", "forEach", "entries", Symbol.iterator]; "keys", "values", "clear", "forEach", "entries", Symbol.iterator];
gConstructorProperties['Set'] = gConstructorProperties.Set =
constructorProps([Symbol.species]); constructorProps([Symbol.species]);
gPrototypeProperties['WeakMap'] = gPrototypeProperties.WeakMap =
["constructor", Symbol.toStringTag, "get", "has", "set", "delete"]; ["constructor", Symbol.toStringTag, "get", "has", "set", "delete"];
gConstructorProperties['WeakMap'] = gConstructorProperties.WeakMap =
constructorProps([]); constructorProps([]);
gPrototypeProperties['WeakSet'] = gPrototypeProperties.WeakSet =
["constructor", Symbol.toStringTag, "has", "add", "delete"]; ["constructor", Symbol.toStringTag, "has", "add", "delete"];
gConstructorProperties['WeakSet'] = gConstructorProperties.WeakSet =
constructorProps([]); constructorProps([]);
gPrototypeProperties['DataView'] = gPrototypeProperties.DataView =
["constructor", "buffer", "byteLength", "byteOffset", Symbol.toStringTag, ["constructor", "buffer", "byteLength", "byteOffset", Symbol.toStringTag,
"getInt8", "getUint8", "getInt16", "getUint16", "getInt8", "getUint8", "getInt16", "getUint16",
"getInt32", "getUint32", "getFloat32", "getFloat64", "getInt32", "getUint32", "getFloat32", "getFloat64",
"setInt8", "setUint8", "setInt16", "setUint16", "setInt8", "setUint8", "setInt16", "setUint16",
"setInt32", "setUint32", "setFloat32", "setFloat64", "setInt32", "setUint32", "setFloat32", "setFloat64",
"getBigInt64", "getBigUint64", "setBigInt64", "setBigUint64"] "getBigInt64", "getBigUint64", "setBigInt64", "setBigUint64"]
gConstructorProperties['DataView'] = constructorProps([]); gConstructorProperties.DataView = constructorProps([]);
// Sort an array that may contain symbols as well as strings. // Sort an array that may contain symbols as well as strings.
function sortProperties(arr) { function sortProperties(arr) {
@ -371,7 +371,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=933681
is(lookupCallable(xray), method, "Proto props resolve on the instance"); is(lookupCallable(xray), method, "Proto props resolve on the instance");
let local = lookupCallable(localProto); let local = lookupCallable(localProto);
is(method.length, local.length, "Function.length identical"); is(method.length, local.length, "Function.length identical");
if (method.length == 0) { if (!method.length) {
is(method.call(xray) + "", local.call(xray) + "", is(method.call(xray) + "", local.call(xray) + "",
"Xray and local method results stringify identically"); "Xray and local method results stringify identically");
@ -426,7 +426,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=933681
// they live in, as far as I can tell, so testing them over Xrays will be // they live in, as far as I can tell, so testing them over Xrays will be
// wrong: on the Xray they will actaully get the lastMatch of _our_ // wrong: on the Xray they will actaully get the lastMatch of _our_
// global, not the Xrayed one. // global, not the Xrayed one.
if (method.length == 0 && if (!method.length &&
!(localCtor.name == "Date" && name == "now") && !(localCtor.name == "Date" && name == "now") &&
!(localCtor.name == "RegExp" && (name == "lastMatch" || name == "$&"))) { !(localCtor.name == "RegExp" && (name == "lastMatch" || name == "$&"))) {
is(method.call(xrayCtor) + "", local.call(xrayCtor) + "", is(method.call(xrayCtor) + "", local.call(xrayCtor) + "",
@ -457,7 +457,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=933681
let protoCallables = protoProps.filter(name => propertyIsGetter(localProto, name, classname) || let protoCallables = protoProps.filter(name => propertyIsGetter(localProto, name, classname) ||
typeof localProto[name] == 'function' && typeof localProto[name] == 'function' &&
name != 'constructor'); name != 'constructor');
ok(protoCallables.length > 0, "Need something to test"); ok(!!protoCallables.length, "Need something to test");
is(xrayProto, iwin[classname].prototype, "Xray proto is correct"); is(xrayProto, iwin[classname].prototype, "Xray proto is correct");
is(xrayProto, xray.__proto__, "Proto accessors agree"); is(xrayProto, xray.__proto__, "Proto accessors agree");
var protoProto = classname == "Object" ? null : iwin.Object.prototype; var protoProto = classname == "Object" ? null : iwin.Object.prototype;
@ -777,7 +777,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=933681
checkThrows(function() { trickyObject.hasOwnProperty = 33; }, /shadow/, checkThrows(function() { trickyObject.hasOwnProperty = 33; }, /shadow/,
"Should reject shadowing of pre-existing inherited properties over Xrays"); "Should reject shadowing of pre-existing inherited properties over Xrays");
checkThrows(function() { Object.defineProperty(trickyObject, 'rejectedProp', { get: function() {}}); }, checkThrows(function() { Object.defineProperty(trickyObject, 'rejectedProp', { get() {}}); },
/accessor property/, "Should reject accessor property definition"); /accessor property/, "Should reject accessor property definition");
} }

View file

@ -1,3 +1,5 @@
// -*- coding: utf-8; indent-tabs-mode: nil -*- // -*- coding: utf-8; indent-tabs-mode: nil -*-
var str = "π”˜π”«π”¦π” π”¬π”‘π”’"; var str = "π”˜π”«π”¦π” π”¬π”‘π”’";
function f() { return 42; } function f() {
return 42;
}