|
1 <!DOCTYPE HTML> |
|
2 <html> |
|
3 <!-- |
|
4 https://bugzilla.mozilla.org/show_bug.cgi?id=806506 |
|
5 --> |
|
6 <head> |
|
7 <title>Test for dynamic changes to content matching content elements</title> |
|
8 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
|
10 </head> |
|
11 <body> |
|
12 <div class="tall" id="bodydiv"></div> |
|
13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=806506">Bug 806506</a> |
|
14 <script> |
|
15 // Create ShadowRoot. |
|
16 var elem = document.createElement("div"); |
|
17 var root = elem.createShadowRoot(); |
|
18 |
|
19 var redInsertionPoint = document.createElement("content"); |
|
20 redInsertionPoint.select = "*[data-color=red]"; |
|
21 |
|
22 var blueInsertionPoint = document.createElement("content"); |
|
23 blueInsertionPoint.select = "*[data-color=blue]"; |
|
24 |
|
25 root.appendChild(redInsertionPoint); |
|
26 root.appendChild(blueInsertionPoint); |
|
27 |
|
28 is(blueInsertionPoint.getDistributedNodes().length, 0, "Blue insertion point should have no distributed nodes."); |
|
29 is(redInsertionPoint.getDistributedNodes().length, 0, "Red insertion point should have no distrubted nodes."); |
|
30 |
|
31 var matchElement = document.createElement("div"); |
|
32 matchElement.setAttribute("data-color", "red"); |
|
33 elem.appendChild(matchElement); |
|
34 |
|
35 is(blueInsertionPoint.getDistributedNodes().length, 0, "Blue insertion point should have no distributed nodes."); |
|
36 is(redInsertionPoint.getDistributedNodes().length, 1, "Red insertion point should match recently inserted div."); |
|
37 |
|
38 matchElement.setAttribute("data-color", "blue"); |
|
39 is(blueInsertionPoint.getDistributedNodes().length, 1, "Blue insertion point should match element after changing attribute value."); |
|
40 is(redInsertionPoint.getDistributedNodes().length, 0, "Red insertion point should not match element after changing attribute value."); |
|
41 |
|
42 matchElement.removeAttribute("data-color"); |
|
43 |
|
44 is(blueInsertionPoint.getDistributedNodes().length, 0, "Blue insertion point should have no distributed nodes after removing the matching attribute."); |
|
45 is(redInsertionPoint.getDistributedNodes().length, 0, "Red insertion point should have no distrubted nodes after removing the matching attribute."); |
|
46 |
|
47 </script> |
|
48 </body> |
|
49 </html> |
|
50 |