|
71 | 71 | document.body.removeChild(iframe);
|
72 | 72 |
|
73 | 73 | test(function () {
|
74 |
| - var windowlessDocument = document.implementation.createHTMLDocument(); |
75 |
| - windowlessDocument.open(); |
76 |
| - windowlessDocument.write('<my-custom-element></my-custom-element>'); |
77 |
| - windowlessDocument.close(); |
| 74 | + var windowlessDocument = (new DOMParser()).parseFromString('<my-custom-element></my-custom-element>', "text/html"); |
78 | 75 |
|
79 | 76 | var instance = windowlessDocument.querySelector('my-custom-element');
|
80 | 77 |
|
81 | 78 | assert_true(instance instanceof HTMLElement);
|
82 | 79 | assert_false(instance instanceof MyCustomElement);
|
83 | 80 |
|
84 |
| -}, 'HTML parser must use the registry of window.document in a document created by document.implementation.createHTMLDocument()'); |
| 81 | +}, 'HTML parser must use the registry of window.document in a document created by DOMParser'); |
85 | 82 |
|
86 | 83 | test(function () {
|
87 | 84 | var windowlessDocument = document.implementation.createDocument ('http://www.w3.org/1999/xhtml', 'html', null);
|
|
108 | 105 | promise_test(function () {
|
109 | 106 | return new Promise(function (resolve, reject) {
|
110 | 107 | var xhr = new XMLHttpRequest();
|
111 |
| - xhr.open('GET', '../resources/empty-html-document.html'); |
| 108 | + xhr.open('GET', '../resources/my-custom-element-html-document.html'); |
112 | 109 | xhr.overrideMimeType('text/xml');
|
113 | 110 | xhr.onload = function () { resolve(xhr.responseXML); }
|
114 | 111 | xhr.onerror = function () { reject('Failed to fetch the document'); }
|
115 | 112 | xhr.send();
|
116 | 113 | }).then(function (doc) {
|
117 |
| - doc.documentElement.innerHTML = '<my-custom-element></my-custom-element>'; |
118 | 114 | var instance = doc.querySelector('my-custom-element');
|
119 | 115 | assert_true(instance instanceof Element);
|
120 |
| - assert_false(instance instanceof MyCustomElement); |
| 116 | + assert_false(instance instanceof MyCustomElement); |
| 117 | + |
| 118 | + doc.documentElement.innerHTML = '<my-custom-element></my-custom-element>'; |
| 119 | + var instance2 = doc.querySelector('my-custom-element'); |
| 120 | + assert_true(instance2 instanceof Element); |
| 121 | + assert_false(instance2 instanceof MyCustomElement); |
121 | 122 | });
|
122 | 123 | }, 'HTML parser must use the registry of window.document in a document created by XMLHttpRequest');
|
123 | 124 |
|
|
0 commit comments