summaryrefslogtreecommitdiffstats
path: root/dom/tests/mochitest/webcomponents/test_custom_element_throw_on_dynamic_markup_insertion.html
diff options
context:
space:
mode:
authorathenian200 <athenian200@outlook.com>2020-01-27 22:59:08 -0600
committerathenian200 <athenian200@outlook.com>2020-01-27 22:59:08 -0600
commit3c4f414db74b84f7d2a6fb13fd888a47a153699b (patch)
treeea81fca559849967a79d598a6f460830762ec9ea /dom/tests/mochitest/webcomponents/test_custom_element_throw_on_dynamic_markup_insertion.html
parent1f8d508258ac5d7d57fc4eb35cac90f28bc8ca03 (diff)
parentc4b0715baaffc541670fd1158557aa7e61e521d3 (diff)
downloadUXP-3c4f414db74b84f7d2a6fb13fd888a47a153699b.tar
UXP-3c4f414db74b84f7d2a6fb13fd888a47a153699b.tar.gz
UXP-3c4f414db74b84f7d2a6fb13fd888a47a153699b.tar.lz
UXP-3c4f414db74b84f7d2a6fb13fd888a47a153699b.tar.xz
UXP-3c4f414db74b84f7d2a6fb13fd888a47a153699b.zip
Merge branch 'master' of https://github.com/MoonchildProductions/UXP into form-disabled-issue
Diffstat (limited to 'dom/tests/mochitest/webcomponents/test_custom_element_throw_on_dynamic_markup_insertion.html')
-rw-r--r--dom/tests/mochitest/webcomponents/test_custom_element_throw_on_dynamic_markup_insertion.html66
1 files changed, 66 insertions, 0 deletions
diff --git a/dom/tests/mochitest/webcomponents/test_custom_element_throw_on_dynamic_markup_insertion.html b/dom/tests/mochitest/webcomponents/test_custom_element_throw_on_dynamic_markup_insertion.html
new file mode 100644
index 000000000..b5ef66860
--- /dev/null
+++ b/dom/tests/mochitest/webcomponents/test_custom_element_throw_on_dynamic_markup_insertion.html
@@ -0,0 +1,66 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1378079
+-->
+<head>
+ <title>Test throw on dynamic markup insertion when creating element synchronously from parser</title>
+ <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
+ <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1378079">Bug 1378079</a>
+<div id="container"></div>
+
+<script>
+
+class DoDocumentOpenInCtor extends HTMLElement {
+ constructor() {
+ super();
+ document.open();
+ }
+};
+customElements.define('x-document-open-in-ctor', DoDocumentOpenInCtor);
+
+class DoDocumentWriteInCtor extends HTMLElement {
+ constructor() {
+ super();
+ document.write('<div>This should not be shown</div>');
+ }
+};
+customElements.define('x-document-write-in-ctor', DoDocumentWriteInCtor);
+
+class DoDocumentCloseInCtor extends HTMLElement {
+ constructor() {
+ super();
+ document.close();
+ }
+};
+customElements.define('x-document-close-in-ctor', DoDocumentCloseInCtor);
+
+window.errors = [];
+window.onerror = function(message, url, lineNumber, columnNumber, error) {
+ errors.push(error.name);
+ return true;
+}
+var expectedErrorCount = 0;
+
+document.write("<x-document-open-in-ctor></x-document-open-in-ctor>");
+expectedErrorCount++;
+is(window.errors.length, expectedErrorCount, "expectedErrorCount should be " + expectedErrorCount);
+is(window.errors[expectedErrorCount - 1], 'InvalidStateError', "Error name should be 'InvalidStateError'");
+
+document.write("<x-document-write-in-ctor></x-document-write-in-ctor>");
+expectedErrorCount++;
+is(window.errors.length, expectedErrorCount, "expectedErrorCount should be " + expectedErrorCount);
+is(window.errors[expectedErrorCount - 1], 'InvalidStateError', "Error name should be 'InvalidStateError'");
+
+document.write("<x-document-close-in-ctor></x-document-close-in-ctor>");
+expectedErrorCount++;
+is(window.errors.length, expectedErrorCount, "expectedErrorCount should be " + expectedErrorCount);
+is(window.errors[expectedErrorCount - 1], 'InvalidStateError', "Error name should be 'InvalidStateError'");
+
+</script>
+
+</body>
+</html>