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

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

Issue 1989343002: Implement :defined pseudo-class selector for Custom Elements (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ce-state
Patch Set: rune and dominicc review, test updated 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 unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/css/CSSSelector.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <script src="../../../resources/testharness.js"></script>
3 <script src="../../../resources/testharnessreport.js"></script>
4 <iframe id="iframe"></iframe>
5 <script>
6 const testList = [
7 { tagName: 'div', defined: true },
8 { tagName: 'a-a', defined: false },
9 { tagName: 'font-face', defined: true },
10 ];
11
12 // Setup iframe to test the parser.
13 const neither = 'rgb(255, 0, 0)';
14 const defined = 'rgb(255, 165, 0)';
15 const not_defined = 'rgb(0, 0, 255)';
16 iframe.srcdoc = `<style>
17 * { color:${neither}; }
18 :defined { color:${defined}; }
19 :not(:defined) { color:${not_defined}; }
20 </style>`
21 + testList.map(d => `<${d.tagName}></${d.tagName}>`).join('');
22 setup({ explicit_done: true });
23 iframe.onload = () => {
24 const doc = iframe.contentDocument;
25 const doc_without_browsing_context = doc.implementation.createHTMLDocument();
26 for (const data of testList) {
27 // Test elements inserted by parser.
28 test_defined(data.defined, doc.getElementsByTagName(data.tagName)[0], `<${da ta.tagName}>`);
29
30 // Test DOM createElement() methods.
31 test_defined_for_createElement(data.defined, doc, data.tagName);
32
33 // Documents without browsing context should be "uncustomized"; i.e., "defin ed".
34 test_defined_for_createElement(true, doc_without_browsing_context, data.tagN ame, 'Without browsing context: ');
35 }
36
37 done();
38 };
39
40 function test_defined_for_createElement(defined, doc, tagName, description = '') {
41 // Test document.createElement().
42 let element = doc.createElement(tagName);
43 doc.body.appendChild(element);
44 test_defined(defined, element, `${description}createElement("${tagName}")`);
45
46 // Test document.createElementNS().
47 element = doc.createElementNS('http://www.w3.org/1999/xhtml', tagName);
48 doc.body.appendChild(element);
49 test_defined(defined, element, `${description}createElementNS("http://www.w3.o rg/1999/xhtml", "${tagName}")`);
50
51 // If the element namespace is not HTML, it should be "uncustomized"; i.e., "d efined".
52 element = doc.createElementNS('http://www.w3.org/2000/svg', tagName);
53 doc.body.appendChild(element);
54 test_defined(true, element, `${description}createElementNS("http://www.w3.org/ 2000/svg", "${tagName}")`);
55 }
56
57 function test_defined(expected, element, description) {
58 test(() => {
59 assert_equals(element.matches(':defined'), expected, 'matches(":defined")');
60 assert_equals(element.matches(':not(:defined)'), !expected, 'matches(":not(: defined")');
61 const view = element.ownerDocument.defaultView;
62 if (!view)
63 return;
64 const style = view.getComputedStyle(element);
65 assert_equals(style.color, expected ? defined : not_defined, 'getComputedSty le');
66 }, `${description} should ${expected ? 'be' : 'not be'} :defined`);
67 }
68 </script>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/css/CSSSelector.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698