blob: 20f33f243abeef901357fb2026f0fe2182277673 [file] [log] [blame]
<!DOCTYPE html>
<meta charset="utf-8">
<title>Interface.prototype.constructor is defined on [[Set]] receiver</title>
<link rel="help" href="https://heycam.github.io/webidl/#interface-prototype-object">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
"use strict";
test(() => {
window.constructor = null;
assert_equals(Window.prototype.constructor, Window);
location.constructor = false;
assert_equals(Location.prototype.constructor, Location);
navigator.constructor = 1;
assert_equals(Navigator.prototype.constructor, Navigator);
document.constructor = {};
assert_equals(HTMLDocument.prototype.constructor, HTMLDocument);
document.head.constructor = [];
assert_equals(HTMLHeadElement.prototype.constructor, HTMLHeadElement);
}, "Window, Location, Navigator, HTMLDocument, and HTMLHeadElement");
test(() => {
for (let key of Object.getOwnPropertyNames(window)) {
if (!/^[A-Z]/.test(key)) continue;
let desc = Object.getOwnPropertyDescriptor(window, key);
if (!desc || desc.enumerable) continue;
let {value} = desc;
if (typeof value !== "function") continue;
let {prototype} = value;
if (!prototype) continue;
let heir = Object.create(prototype);
let newConstructor = function() {};
heir.constructor = newConstructor;
assert_not_equals(prototype.constructor, newConstructor, key);
assert_own_property(heir, "constructor", key);
assert_equals(heir.constructor, newConstructor, key);
}
}, "All window.* constructors");
</script>