Skip to content

Commit

Permalink
Merge f93145f into e74476b
Browse files Browse the repository at this point in the history
  • Loading branch information
jugglinmike authored Jun 6, 2017
2 parents e74476b + f93145f commit 89aead7
Showing 1 changed file with 77 additions and 0 deletions.
77 changes: 77 additions & 0 deletions resources/idlharness.js
Original file line number Diff line number Diff line change
Expand Up @@ -1137,6 +1137,83 @@ IdlInterface.prototype.test_self = function()
}
}.bind(this), this.name + " interface: existence and properties of interface prototype object");

if (this.is_global() && typeof Object.setPrototypeOf === "function") {
// These functions test WebIDL as of 2017-06-06.
// https://heycam.github.io/webidl/#platform-object-setprototypeof
test(function() {
var originalValue = Object.getPrototypeOf(self[this.name].prototype);
var newValue = Object.create(null);

assert_throws(new TypeError(), function() {
Object.setPrototypeOf(self[this.name].prototype, newValue);
});

assert_equals(
Object.getPrototypeOf(self[this.name].prototype),
originalValue,
"original value not modified"
);
}.bind(this), this.name + " interface: internal [[SetPrototypeOf]] method " +
"of global platform object - setting to a new value via Object.setPrototypeOf " +
"should throw a TypeError");

test(function() {
var originalValue = Object.getPrototypeOf(self[this.name].prototype);
var newValue = Object.create(null);

assert_throws(new TypeError(), function() {
self[this.name].prototype.__proto__ = newValue;
});

assert_equals(
Object.getPrototypeOf(self[this.name].prototype),
originalValue,
"original value not modified"
);
}.bind(this), this.name + " interface: internal [[SetPrototypeOf]] method " +
"of global platform object - setting to a new value via __proto__ " +
"should throw a TypeError");

test(function() {
var originalValue = Object.getPrototypeOf(self[this.name].prototype);
var newValue = Object.create(null);

assert_false(Reflect.setPrototypeOf(self[this.name].prototype.__proto__, newValue));

assert_equals(
Object.getPrototypeOf(self[this.name].prototype),
originalValue,
"original value not modified"
);
}.bind(this), this.name + " interface: internal [[SetPrototypeOf]] method " +
"of global platform object - setting to a new value via Reflect.setPrototypeOf " +
"should return false");

test(function() {
var originalValue = Object.getPrototypeOf(self[this.name].prototype);

Object.setPrototypeOf(self[this.name].prototype, originalValue);
}.bind(this), this.name + " interface: internal [[SetPrototypeOf]] method " +
"of global platform object - setting to its original value via Object.setPrototypeOf " +
"should not throw");

test(function() {
var originalValue = Object.getPrototypeOf(self[this.name].prototype);

self[this.name].prototype.__proto__ = originalValue;
}.bind(this), this.name + " interface: internal [[SetPrototypeOf]] method " +
"of global platform object - setting to its original value via __proto__ " +
"should not throw");

test(function() {
var originalValue = Object.getPrototypeOf(self[this.name].prototype);

assert_true(Reflect.setPrototypeOf(self[this.name].prototype, originalValue));
}.bind(this), this.name + " interface: internal [[SetPrototypeOf]] method " +
"of global platform object - setting to its original value via Reflect.setPrototypeOf " +
"should return true");
}

test(function()
{
if (this.is_callback() && !this.has_constants()) {
Expand Down

0 comments on commit 89aead7

Please sign in to comment.