Last active
October 7, 2023 23:24
-
-
Save jorendorff/0627479bde2eeaa410f1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Before: | |
// Test constructors that can be instantiated with zero arguments. | |
for (var c of simpleConstructors) { | |
ok(iwin[c], "Constructors appear: " + c); | |
is(iwin[c], Cu.unwaiveXrays(iwin.wrappedJSObject[c]), | |
"we end up with the appropriate constructor: " + c); | |
is(Cu.unwaiveXrays(Cu.waiveXrays(new iwin[c]).constructor), iwin[c], | |
"constructor property is set up right: " + c); | |
let expectedProto = /Opaque/.test(new iwin[c]) ? iwin['Object'].prototype | |
: iwin[c].prototype; | |
is(Object.getPrototypeOf(new iwin[c]), expectedProto, | |
"prototype is correct: " + c); | |
is(global(new iwin[c]), iwin, "Got the right global: " + c); | |
} | |
After: | |
// Test constructors that can be instantiated with zero arguments. | |
var waiveXrays = Components.utils.waiveXrays; | |
var unwaiveXrays = Components.utils.unwaiveXrays; | |
for (var name of simpleConstructors) { | |
let constructor = childWindow[name]; | |
ok(constructor, "Constructors appear: " + name); | |
is(constructor, unwaiveXrays(childWindow.wrappedJSObject[name]), | |
"we end up with the appropriate constructor: " + name); | |
let instance = new constructor; | |
is(unwaiveXrays(waiveXrays(instance).constructor), constructor, | |
"constructor property is set up right: " + name); | |
let expectedProto = /Opaque/.test(instance) ? childWindow.Object.prototype | |
: constructor.prototype; | |
is(Object.getPrototypeOf(instance), expectedProto, | |
"prototype is correct: " + name); | |
is(global(instance), childWindow, "Got the right global: " + name); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment