OLD | NEW |
| (Empty) |
1 <sky> | |
2 <script> | |
3 import "../resources/third_party/unittest/unittest.dart"; | |
4 import "../resources/unit.dart"; | |
5 | |
6 import "dart:sky"; | |
7 | |
8 void main() { | |
9 initUnit(); | |
10 | |
11 test("should return null for elements not a child of a scope", () { | |
12 var doc = new Document(); | |
13 var element = doc.createElement("div"); | |
14 expect(element.owner, isNull); | |
15 }); | |
16 test("should return the document for elements in the document scope", () { | |
17 var doc = new Document(); | |
18 var element = doc.createElement("div"); | |
19 doc.appendChild(element); | |
20 expect(element.owner, equals(doc)); | |
21 }); | |
22 test("should return the shadow root for elements in the shadow root scope", ()
{ | |
23 var doc = new Document(); | |
24 var host = doc.createElement("div"); | |
25 var child = doc.createElement("div"); | |
26 var shadowRoot = host.ensureShadowRoot(); | |
27 shadowRoot.appendChild(child); | |
28 expect(child.owner, equals(shadowRoot)); | |
29 }); | |
30 test("should return self for a shadow root or document", () { | |
31 var doc = new Document(); | |
32 var host = doc.createElement("div"); | |
33 doc.appendChild(host); | |
34 var shadowRoot = host.ensureShadowRoot(); | |
35 expect(shadowRoot.owner, equals(shadowRoot)); | |
36 expect(doc.owner, equals(doc)); | |
37 }); | |
38 test("should dynamically update", () { | |
39 var doc = new Document(); | |
40 var host = doc.createElement("div"); | |
41 var child = doc.createElement("div"); | |
42 var shadowRoot = host.ensureShadowRoot(); | |
43 expect(child.owner, isNull); | |
44 shadowRoot.appendChild(child); | |
45 expect(child.owner, equals(shadowRoot)); | |
46 child.remove(); | |
47 expect(child.owner, isNull); | |
48 }); | |
49 } | |
50 </script> | |
51 </sky> | |
OLD | NEW |