gecko-dev/testing/web-platform/tests/WebIDL/ecmascript-binding/es-exceptions/DOMException-custom-bindings.any.js
James Graham 2dc7a68af1 Bug 1386604 - Update web-platform-tests to revision 8b5316ad93c6c1238eea26a3d8052e32b34bbabd, a=testonly
MozReview-Commit-ID: 3HXcvTYpAkA


--HG--
rename : testing/web-platform/tests/fonts/matching/README.md => testing/web-platform/tests/css-fonts/matching/README.md
rename : testing/web-platform/tests/fonts/matching/fixed-stretch-style-over-weight-ref.html => testing/web-platform/tests/css-fonts/matching/fixed-stretch-style-over-weight-ref.html
rename : testing/web-platform/tests/fonts/matching/fixed-stretch-style-over-weight.html => testing/web-platform/tests/css-fonts/matching/fixed-stretch-style-over-weight.html
rename : testing/web-platform/tests/fonts/matching/font-matching.css => testing/web-platform/tests/css-fonts/matching/font-matching.css
rename : testing/web-platform/tests/fonts/matching/resources/variabletest_matching.ttf => testing/web-platform/tests/css-fonts/matching/resources/variabletest_matching.ttf
rename : testing/web-platform/tests/fonts/matching/stretch-distance-over-weight-distance-ref.html => testing/web-platform/tests/css-fonts/matching/stretch-distance-over-weight-distance-ref.html
rename : testing/web-platform/tests/fonts/matching/stretch-distance-over-weight-distance.html => testing/web-platform/tests/css-fonts/matching/stretch-distance-over-weight-distance.html
rename : testing/web-platform/tests/fonts/matching/style-ranges-over-weight-direction-ref.html => testing/web-platform/tests/css-fonts/matching/style-ranges-over-weight-direction-ref.html
rename : testing/web-platform/tests/fonts/matching/style-ranges-over-weight-direction.html => testing/web-platform/tests/css-fonts/matching/style-ranges-over-weight-direction.html
rename : testing/web-platform/tests/payment-request/OWNERS => testing/web-platform/tests/payment-method-id/OWNERS
rename : testing/web-platform/tests/storage/interfaces.worker.js => testing/web-platform/tests/storage/interfaces.https.worker.js
rename : testing/web-platform/tests/tools/browserutils/requirements.txt => testing/web-platform/tests/tools/wpt/requirements.txt
rename : testing/web-platform/tests/tools/browserutils/utils.py => testing/web-platform/tests/tools/wpt/utils.py
rename : testing/web-platform/tests/tools/wptrunner/wptrunner/executors/reftest-wait.js => testing/web-platform/tests/tools/wptrunner/wptrunner/executors/reftest-wait_marionette.js
rename : testing/web-platform/tests/uievents/keyboard/key-manual.css => testing/web-platform/tests/uievents/keyboard/key.css
rename : testing/web-platform/tests/uievents/keyboard/key-manual.js => testing/web-platform/tests/uievents/keyboard/key.js
2017-08-03 11:31:54 +01:00

120 lines
4.9 KiB
JavaScript

"use strict";
test(() => {
assert_throws(new TypeError(), () => DOMException());
}, "Cannot construct without new");
test(() => {
assert_equals(Object.getPrototypeOf(DOMException.prototype), Error.prototype);
}, "inherits from Error: prototype-side");
test(() => {
assert_equals(Object.getPrototypeOf(DOMException), Function.prototype);
}, "does not inherit from Error: class-side");
test(() => {
const e = new DOMException("message", "name");
assert_false(e.hasOwnProperty("message"), "property is not own");
const propDesc = Object.getOwnPropertyDescriptor(DOMException.prototype, "message");
assert_equals(typeof propDesc.get, "function", "property descriptor is a getter");
assert_equals(propDesc.set, undefined, "property descriptor is not a setter");
assert_true(propDesc.enumerable, "property descriptor enumerable");
assert_true(propDesc.configurable, "property descriptor configurable");
}, "message property descriptor");
test(() => {
const getter = Object.getOwnPropertyDescriptor(DOMException.prototype, "message").get;
assert_throws(new TypeError(), () => getter.apply({}));
}, "message getter performs brand checks (i.e. is not [LenientThis]");
test(() => {
const e = new DOMException("message", "name");
assert_false(e.hasOwnProperty("name"), "property is not own");
const propDesc = Object.getOwnPropertyDescriptor(DOMException.prototype, "name");
assert_equals(typeof propDesc.get, "function", "property descriptor is a getter");
assert_equals(propDesc.set, undefined, "property descriptor is not a setter");
assert_true(propDesc.enumerable, "property descriptor enumerable");
assert_true(propDesc.configurable, "property descriptor configurable");
}, "name property descriptor");
test(() => {
const getter = Object.getOwnPropertyDescriptor(DOMException.prototype, "name").get;
assert_throws(new TypeError(), () => getter.apply({}));
}, "name getter performs brand checks (i.e. is not [LenientThis]");
test(() => {
const e = new DOMException("message", "name");
assert_false(e.hasOwnProperty("code"), "property is not own");
const propDesc = Object.getOwnPropertyDescriptor(DOMException.prototype, "code");
assert_equals(typeof propDesc.get, "function", "property descriptor is a getter");
assert_equals(propDesc.set, undefined, "property descriptor is not a setter");
assert_true(propDesc.enumerable, "property descriptor enumerable");
assert_true(propDesc.configurable, "property descriptor configurable");
}, "code property descriptor");
test(() => {
const getter = Object.getOwnPropertyDescriptor(DOMException.prototype, "code").get;
assert_throws(new TypeError(), () => getter.apply({}));
}, "code getter performs brand checks (i.e. is not [LenientThis]");
test(() => {
const e = new DOMException("message", "InvalidCharacterError");
assert_equals(e.code, 5, "Initially the code is set to 5");
Object.defineProperty(e, "name", {
value: "WrongDocumentError"
});
assert_equals(e.code, 5, "The code is still set to 5");
}, "code property is not affected by shadowing the name property");
test(() => {
const e = new DOMException("message", "name");
assert_equals(Object.prototype.toString.call(e), "[object DOMException]");
}, "Object.prototype.toString behavior is like other interfaces");
test(() => {
const e = new DOMException("message", "name");
assert_false(e.hasOwnProperty("toString"), "toString must not exist on the instance");
assert_false(DOMException.prototype.hasOwnProperty("toString"), "toString must not exist on DOMException.prototype");
assert_equals(typeof e.toString, "function", "toString must still exist (via Error.prototype)");
}, "Inherits its toString() from Error.prototype");
test(() => {
const e = new DOMException("message", "name");
assert_equals(e.toString(), "name: message",
"The default Error.prototype.toString() behavior must work on supplied name and message");
Object.defineProperty(e, "name", { value: "new name" });
Object.defineProperty(e, "message", { value: "new message" });
assert_equals(e.toString(), "new name: new message",
"The default Error.prototype.toString() behavior must work on shadowed names and messages");
}, "toString() behavior from Error.prototype applies as expected");
test(() => {
assert_throws(new TypeError(), () => DOMException.prototype.toString());
}, "DOMException.prototype.toString() applied to DOMException.prototype throws because of name/message brand checks");
test(() => {
let stackOnNormalErrors;
try {
throw new Error("normal error");
} catch (e) {
stackOnNormalErrors = e.stack;
}
let stackOnDOMException;
try {
throw new DOMException("message", "name");
} catch (e) {
stackOnDOMException = e.stack;
}
assert_equals(typeof stackOnDOMException, typeof stackOnNormalErrors, "The typeof values must match");
}, "If the implementation has a stack property on normal errors, it also does on DOMExceptions");