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

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: Fix DCHECK 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 <div id="log"></div>
rune 2016/05/25 23:43:07 Is the #log element necessary?
kojii 2016/05/26 01:25:40 Good point. Until recently, our testharnessreport.
5 <iframe id="iframe"></iframe>
6 <script>
7 const testList = [
8 { name: 'div', defined: true },
9 { name: 'a-a', defined: false },
10 { name: 'font-face', defined: true },
11 ];
12
13 // Setup iframe to test the parser.
14 const neither = 'rgb(255, 0, 0)';
15 const defined = 'rgb(255, 165, 0)';
16 const not_defined = 'rgb(0, 0, 255)';
17 iframe.srcdoc = '<style>'
18 + `* { color:${neither}; }`
rune 2016/05/25 23:43:07 Looks like you're mixing single-quotes and back-ti
kojii 2016/05/26 01:25:40 Only back-ticks does template literals which I rec
kojii 2016/05/26 04:49:43 I happen to find the back-ticks support new-lines
rune 2016/05/26 07:16:27 No looks good now. Excuse my ES6 ignorance. I didn
19 + `:defined { color:${defined}; }`
20 + `:not(:defined) { color:${not_defined}; }`
21 + '</style>'
22 + testList.map(d => `<${d.name}></${d.name}>`).join('');
23 setup({ explicit_done: true });
24 iframe.onload = () => {
25 const doc = iframe.contentDocument;
26
27 for (const data of testList) {
28 test_defined(data.defined, doc.getElementsByTagName(data.name)[0], `<${data. name}>`);
29
30 let element = doc.createElement(data.name);
31 doc.body.appendChild(element);
32 test_defined(data.defined, element, `createElement("${data.name}")`);
33
34 element = doc.createElementNS('http://www.w3.org/1999/xhtml', data.name);
35 doc.body.appendChild(element);
36 test_defined(data.defined, element, `createElementNS("http://www.w3.org/1999 /xhtml", "${data.name}")`);
37
38 element = doc.createElementNS('http://www.w3.org/2000/svg', data.name);
39 doc.body.appendChild(element);
40 test_defined(true, element, `createElementNS("http://www.w3.org/2000/svg", " ${data.name}")`);
41 }
42
43 function test_defined(expected, element, description) {
44 test(() => {
45 assert_equals(element.matches(':defined'), expected, 'matches(":defined")' );
46 assert_equals(element.matches(':not(:defined)'), !expected, 'matches(":not (:defined")');
47 assert_equals(doc.defaultView.getComputedStyle(element).color, expected ? defined : not_defined, 'getComputedStyle');
48 }, `${description} should ${expected ? 'be' : 'not be'} :defined`);
49 }
50
51 done();
52 };
53 </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