File: test_custom_element_define_parser.html

package info (click to toggle)
firefox 143.0.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,617,328 kB
  • sloc: cpp: 7,478,492; javascript: 6,417,157; ansic: 3,720,058; python: 1,396,372; xml: 627,523; asm: 438,677; java: 186,156; sh: 63,477; makefile: 19,171; objc: 13,059; perl: 12,983; yacc: 4,583; cs: 3,846; pascal: 3,405; lex: 1,720; ruby: 1,003; exp: 762; php: 436; lisp: 258; awk: 247; sql: 66; sed: 53; csh: 10
file content (61 lines) | stat: -rw-r--r-- 1,808 bytes parent folder | download | duplicates (31)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=783129
-->
<head>
  <title>Test for customElements.define for elements created by the parser</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
<script>

var uncaughtError;
window.onerror = function(message, url, lineNumber, columnNumber, error) {
  uncaughtError = error;
};

var isConnectedCallbackCalled = false;
class XButton extends HTMLButtonElement {
  connectedCallback() {
    ok(!isConnectedCallbackCalled, "ConnectedCallback should only be called once.");
    is(this.tagName, "BUTTON", "Only the <button> element should be upgraded.");
    isConnectedCallbackCalled = true;
  }
};

customElements.define("x-button", XButton, { extends: "button" });

class XDiv extends HTMLDivElement {
  constructor() {
    // Queue a task to check error and callbacks.
    setTimeout(() => {
      ok(isConnectedCallbackCalled, "ConnectedCallback should be called.");
      ok(uncaughtError instanceof TypeError,
       "TypeError should be filed for upgrading <x-div> element.");
      SimpleTest.finish();
    }, 0);
    super();
  }

  connectedCallback() {
    ok(false, "Connected callback for x-div should not be called.");
  }
};

customElements.define("x-div", XDiv);

SimpleTest.waitForExplicitFinish();

</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=783129">Bug 783129</a>
<button is="x-button"></button><!-- should be upgraded -->
<x-button></x-button><!-- should not be upgraded -->
<span is="x-button"></span><!-- should not be upgraded -->
<div is="x-div"></div><!-- should not be upgraded -->
<x-div></x-div><!-- should be upgraded, but failed -->
<script>
</script>
</body>
</html>