Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(880)

Unified Diff: third_party/WebKit/LayoutTests/custom-elements/spec/selectors/pseudo-class-defined.html

Issue 2039103004: Add tests of state changes for :defined() selector (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: dominicc review Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/custom-elements/spec/selectors/pseudo-class-defined.html
diff --git a/third_party/WebKit/LayoutTests/custom-elements/spec/selectors/pseudo-class-defined.html b/third_party/WebKit/LayoutTests/custom-elements/spec/selectors/pseudo-class-defined.html
index a248f121b1ae9c9f8e2dc78ff829c16b4af62cdc..b2cd70c290c1b2a90020677c309c61dd7a83df8e 100644
--- a/third_party/WebKit/LayoutTests/custom-elements/spec/selectors/pseudo-class-defined.html
+++ b/third_party/WebKit/LayoutTests/custom-elements/spec/selectors/pseudo-class-defined.html
@@ -4,9 +4,9 @@
<iframe id="iframe"></iframe>
<script>
const testList = [
- { tagName: 'div', defined: true },
- { tagName: 'a-a', defined: false },
- { tagName: 'font-face', defined: true },
+ { tag_name: 'div', defined: true },
+ { tag_name: 'a-a', defined: false },
+ { tag_name: 'font-face', defined: true },
];
// Setup iframe to test the parser.
@@ -18,40 +18,51 @@ iframe.srcdoc = `<style>
:defined { color:${defined}; }
:not(:defined) { color:${not_defined}; }
</style>`
- + testList.map(d => `<${d.tagName}></${d.tagName}>`).join('');
+ + testList.map(d => `<${d.tag_name}></${d.tag_name}>`).join('');
setup({ explicit_done: true });
iframe.onload = () => {
const doc = iframe.contentDocument;
const doc_without_browsing_context = doc.implementation.createHTMLDocument();
for (const data of testList) {
// Test elements inserted by parser.
- test_defined(data.defined, doc.getElementsByTagName(data.tagName)[0], `<${data.tagName}>`);
+ test_defined(data.defined, doc.getElementsByTagName(data.tag_name)[0], `<${data.tag_name}>`);
// Test DOM createElement() methods.
- test_defined_for_createElement(data.defined, doc, data.tagName);
+ test_defined_for_createElement(data.defined, doc, data.tag_name);
// Documents without browsing context should be "uncustomized"; i.e., "defined".
- test_defined_for_createElement(true, doc_without_browsing_context, data.tagName, 'Without browsing context: ');
+ test_defined_for_createElement(true, doc_without_browsing_context, data.tag_name, 'Without browsing context: ');
}
done();
};
-function test_defined_for_createElement(defined, doc, tagName, description = '') {
+function test_defined_for_createElement(defined, doc, tag_name, description = '') {
// Test document.createElement().
- let element = doc.createElement(tagName);
+ let element = doc.createElement(tag_name);
doc.body.appendChild(element);
- test_defined(defined, element, `${description}createElement("${tagName}")`);
+ test_defined(defined, element, `${description}createElement("${tag_name}")`);
// Test document.createElementNS().
- element = doc.createElementNS('http://www.w3.org/1999/xhtml', tagName);
- doc.body.appendChild(element);
- test_defined(defined, element, `${description}createElementNS("http://www.w3.org/1999/xhtml", "${tagName}")`);
+ let html_element = doc.createElementNS('http://www.w3.org/1999/xhtml', tag_name);
+ doc.body.appendChild(html_element);
+ test_defined(defined, html_element, `${description}createElementNS("http://www.w3.org/1999/xhtml", "${tag_name}")`);
// If the element namespace is not HTML, it should be "uncustomized"; i.e., "defined".
- element = doc.createElementNS('http://www.w3.org/2000/svg', tagName);
- doc.body.appendChild(element);
- test_defined(true, element, `${description}createElementNS("http://www.w3.org/2000/svg", "${tagName}")`);
+ let svg_element = doc.createElementNS('http://www.w3.org/2000/svg', tag_name);
+ doc.body.appendChild(svg_element);
+ test_defined(true, svg_element, `${description}createElementNS("http://www.w3.org/2000/svg", "${tag_name}")`);
+
+ // Test ":defined" changes when the custom element was defined.
+ if (!defined) {
+ let w = doc.defaultView;
+ w.customElements.define(tag_name, class extends w.HTMLElement {
+ constructor() { super(); }
+ });
+
+ test_defined(true, element, `Upgraded ${description}createElement("${tag_name}")`);
+ test_defined(true, html_element, `Upgraded ${description}createElementNS("http://www.w3.org/1999/xhtml", "${tag_name}")`);
+ }
}
function test_defined(expected, element, description) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698