diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 19:33:14 +0000 |
commit | 36d22d82aa202bb199967e9512281e9a53db42c9 (patch) | |
tree | 105e8c98ddea1c1e4784a60a5a6410fa416be2de /testing/web-platform/tests/html/browsers/the-windowproxy-exotic-object | |
parent | Initial commit. (diff) | |
download | firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.tar.xz firefox-esr-36d22d82aa202bb199967e9512281e9a53db42c9.zip |
Adding upstream version 115.7.0esr.upstream/115.7.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/html/browsers/the-windowproxy-exotic-object')
8 files changed, 241 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/browsers/the-windowproxy-exotic-object/document-tree-child-browsing-context-name-property-set.sub.html b/testing/web-platform/tests/html/browsers/the-windowproxy-exotic-object/document-tree-child-browsing-context-name-property-set.sub.html new file mode 100644 index 0000000000..171aa01999 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-windowproxy-exotic-object/document-tree-child-browsing-context-name-property-set.sub.html @@ -0,0 +1,26 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>document-tree child browsing context name property set</title> +<link rel="help" href="https://html.spec.whatwg.org/C/#document-tree-child-browsing-context-name-property-set"> + +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> + +<iframe src="//{{domains[www]}}:{{ports[http][1]}}/common/window-name-setter.html#spices"></iframe> +<iframe name="spices"></iframe> +<iframe name="fruits"></iframe> + +<script> +"use strict"; +setup({ explicit_done: true }); + +window.onload = () => { + test(() => { + assert_equals(window.spices, undefined); + assert_not_equals(window.fruits, undefined); + assert_equals(window.fruits, window[2]); + }, "Cross origin child window's name shadows the second candidate of a same origin iframe"); + + done(); +}; +</script> diff --git a/testing/web-platform/tests/html/browsers/the-windowproxy-exotic-object/windowproxy-define-own-property-unforgeable-same-origin.html b/testing/web-platform/tests/html/browsers/the-windowproxy-exotic-object/windowproxy-define-own-property-unforgeable-same-origin.html new file mode 100644 index 0000000000..ac4eb458c3 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-windowproxy-exotic-object/windowproxy-define-own-property-unforgeable-same-origin.html @@ -0,0 +1,47 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>[[DefineOwnProperty]] on a WindowProxy forwards to OrdinaryDefineOwnProperty for same-origin objects</title> +<link rel="help" href="https://html.spec.whatwg.org/multipage/window-object.html#windowproxy-defineownproperty"> + +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> + +<script> +"use strict"; + +for (const key of ["window", "document", "location", "top"]) { + const { get, set } = Object.getOwnPropertyDescriptor(window, key); + + test(() => { + Object.defineProperty(window, key, {}); + assert_true(Reflect.defineProperty(window, key, { configurable: false }), "[[Configurable]]: false"); + Object.defineProperty(window, key, { enumerable: true }); + + assert_true(Reflect.defineProperty(window, key, { get }), "[[Get]]: unchanged"); + Object.defineProperty(window, key, { set }); + assert_true(Reflect.defineProperty(window, key, { get, set }), "[[Get]]: unchanged, [[Set]]: unchanged"); + + Object.defineProperty(window, key, { get, set, enumerable: true, configurable: false }); + }, `[[DefineOwnProperty]] success: "${key}"`); + + test(() => { + assert_throws_js(TypeError, () => { + Object.defineProperty(window, key, { configurable: true }); + }, "[[Configurable]]: true"); + + assert_false(Reflect.defineProperty(window, key, { enumerable: false }), "[[Enumerable]]: false"); + + assert_throws_js(TypeError, () => { + Object.defineProperty(window, key, { get() {}, set }); + }, "[[Get]]: changed, [[Set]]: unchanged"); + + assert_false(Reflect.defineProperty(window, key, { get, set() {} }), "[[Get]]: unchanged, [[Set]]: changed"); + + assert_throws_js(TypeError, () => { + Object.defineProperty(window, key, { writable: false, configurable: true }); + }, "[[Writable]]: false, [[Configurable]]: true"); + + assert_false(Reflect.defineProperty(window, key, { value: window[key], enumerable: true }), "[[Value]], [[Enumerable]]: true"); + }, `[[DefineOwnProperty]] failure: "${key}"`); +} +</script> diff --git a/testing/web-platform/tests/html/browsers/the-windowproxy-exotic-object/windowproxy-prevent-extensions.html b/testing/web-platform/tests/html/browsers/the-windowproxy-exotic-object/windowproxy-prevent-extensions.html new file mode 100644 index 0000000000..97a156290a --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-windowproxy-exotic-object/windowproxy-prevent-extensions.html @@ -0,0 +1,21 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>[[PreventExtensions]] on a WindowProxy object should return false</title> +<link rel="help" href="https://html.spec.whatwg.org/multipage/window-object.html#windowproxy-preventextensions"> + +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> + +<script> +"use strict"; + +test(() => { + assert_throws_js(TypeError, () => { + Object.preventExtensions(window); + }); +}, "Object.preventExtensions throws a TypeError"); + +test(() => { + assert_false(Reflect.preventExtensions(window)); +}, "Reflect.preventExtensions returns false"); +</script> diff --git a/testing/web-platform/tests/html/browsers/the-windowproxy-exotic-object/windowproxy-prototype-setting-cross-origin-domain.sub.html b/testing/web-platform/tests/html/browsers/the-windowproxy-exotic-object/windowproxy-prototype-setting-cross-origin-domain.sub.html new file mode 100644 index 0000000000..a5ae78cc87 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-windowproxy-exotic-object/windowproxy-prototype-setting-cross-origin-domain.sub.html @@ -0,0 +1,29 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>[[SetPrototypeOf]] on a WindowProxy object should not allow changing its value: cross-origin via document.domain</title> +<link rel="help" href="http://html.spec.whatwg.org/multipage/#windowproxy-setprototypeof"> +<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me"> + +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/test-setting-immutable-prototype.js"></script> + +<iframe src="/common/domain-setter.sub.html"></iframe> + +<script> +"use strict"; +// This page does *not* set document.domain, so it's cross-origin with the iframe +setup({ explicit_done: true }); + +window.onload = () => { + const target = frames[0]; + + test(() => { + assert_equals(Object.getPrototypeOf(target), null); + }, "Cross-origin via document.domain: the prototype is null"); + + testSettingImmutablePrototype("Cross-origin via document.domain", target, null, { isSameOriginDomain: false }); + + done(); +}; +</script> diff --git a/testing/web-platform/tests/html/browsers/the-windowproxy-exotic-object/windowproxy-prototype-setting-cross-origin.sub.html b/testing/web-platform/tests/html/browsers/the-windowproxy-exotic-object/windowproxy-prototype-setting-cross-origin.sub.html new file mode 100644 index 0000000000..a5c1a2f102 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-windowproxy-exotic-object/windowproxy-prototype-setting-cross-origin.sub.html @@ -0,0 +1,28 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>[[SetPrototypeOf]] on a WindowProxy object should not allow changing its value: cross-origin</title> +<link rel="help" href="http://html.spec.whatwg.org/multipage/#windowproxy-setprototypeof"> +<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me"> + +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/test-setting-immutable-prototype.js"></script> + +<iframe src="//{{domains[www]}}:{{ports[http][1]}}/common/blank.html"></iframe> + +<script> +"use strict"; +setup({ explicit_done: true }); + +window.onload = () => { + const target = frames[0]; + + test(() => { + assert_equals(Object.getPrototypeOf(target), null); + }, "Cross-origin: the prototype is null"); + + testSettingImmutablePrototype("Cross-origin", target, null, { isSameOriginDomain: false }); + + done(); +}; +</script> diff --git a/testing/web-platform/tests/html/browsers/the-windowproxy-exotic-object/windowproxy-prototype-setting-goes-cross-origin-domain.sub.html b/testing/web-platform/tests/html/browsers/the-windowproxy-exotic-object/windowproxy-prototype-setting-goes-cross-origin-domain.sub.html new file mode 100644 index 0000000000..239fa6ddf2 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-windowproxy-exotic-object/windowproxy-prototype-setting-goes-cross-origin-domain.sub.html @@ -0,0 +1,39 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>[[SetPrototypeOf]] on a WindowProxy object should not allow changing its value: cross-origin via document.domain after initially getting the object</title> +<link rel="help" href="http://html.spec.whatwg.org/multipage/#windowproxy-setprototypeof"> +<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me"> + +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/test-setting-immutable-prototype.js"></script> + +<iframe src="/common/blank.html"></iframe> + +<script> +"use strict"; +setup({ explicit_done: true }); + +window.onload = () => { + const target = frames[0]; + const origProto = Object.getPrototypeOf(target); + + test(() => { + assert_not_equals(origProto, null); + }, "Same-origin (for now): the prototype is accessible"); + + document.domain = "{{host}}"; + + test(() => { + assert_equals(Object.getPrototypeOf(target), null); + }, "Became cross-origin via document.domain: the prototype is now null"); + + testSettingImmutablePrototype("Became cross-origin via document.domain", target, null, { isSameOriginDomain: false }); + + testSettingImmutablePrototypeToNewValueOnly( + "Became cross-origin via document.domain", target, origProto, + "the original value from before going cross-origin", { isSameOriginDomain: false }); + + done(); +}; +</script> diff --git a/testing/web-platform/tests/html/browsers/the-windowproxy-exotic-object/windowproxy-prototype-setting-same-origin-domain.sub.html b/testing/web-platform/tests/html/browsers/the-windowproxy-exotic-object/windowproxy-prototype-setting-same-origin-domain.sub.html new file mode 100644 index 0000000000..fb18822ac5 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-windowproxy-exotic-object/windowproxy-prototype-setting-same-origin-domain.sub.html @@ -0,0 +1,30 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>[[SetPrototypeOf]] on a WindowProxy object should not allow changing its value: cross-origin, but same-origin-domain</title> +<link rel="help" href="http://html.spec.whatwg.org/multipage/#windowproxy-setprototypeof"> +<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me"> + +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/test-setting-immutable-prototype.js"></script> + +<iframe src="//{{domains[www]}}:{{ports[http][1]}}/common/domain-setter.sub.html"></iframe> + +<script> +"use strict"; +document.domain = "{{host}}"; +setup({ explicit_done: true }); + +window.onload = () => { + const target = frames[0]; + const origProto = Object.getPrototypeOf(target); + + test(() => { + assert_not_equals(origProto, null); + }, "Same-origin-domain prerequisite check: the original prototype is accessible"); + + testSettingImmutablePrototype("Same-origin-domain", target, origProto, { isSameOriginDomain: true }, frames[0]); + + done(); +}; +</script> diff --git a/testing/web-platform/tests/html/browsers/the-windowproxy-exotic-object/windowproxy-prototype-setting-same-origin.html b/testing/web-platform/tests/html/browsers/the-windowproxy-exotic-object/windowproxy-prototype-setting-same-origin.html new file mode 100644 index 0000000000..5779199ca3 --- /dev/null +++ b/testing/web-platform/tests/html/browsers/the-windowproxy-exotic-object/windowproxy-prototype-setting-same-origin.html @@ -0,0 +1,21 @@ +<!DOCTYPE html> +<meta charset="utf-8"> +<title>[[SetPrototypeOf]] on a WindowProxy object should not allow changing its value: same-origin</title> +<link rel="help" href="http://html.spec.whatwg.org/multipage/#windowproxy-setprototypeof"> +<link rel="author" title="Domenic Denicola" href="mailto:d@domenic.me"> + +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/common/test-setting-immutable-prototype.js"></script> + +<script> +"use strict"; + +const origProto = Object.getPrototypeOf(window); + +test(() => { + assert_not_equals(origProto, null); +}, "Same-origin prerequisite check: the original prototype is accessible"); + +testSettingImmutablePrototype("Same-origin", window, origProto, { isSameOriginDomain: true }); +</script> |