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

Side by Side Diff: sky/tests/dom/ownerScope.sky

Issue 924203002: Morph the APIs for Node, ParentNode, and Element closer to the specs (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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
OLDNEW
1 <sky> 1 <sky>
2 <script> 2 <script>
3 import "../resources/third_party/unittest/unittest.dart"; 3 import "../resources/third_party/unittest/unittest.dart";
4 import "../resources/unit.dart"; 4 import "../resources/unit.dart";
5 5
6 import "dart:sky"; 6 import "dart:sky";
7 7
8 void main() { 8 void main() {
9 initUnit(); 9 initUnit();
10 10
11 test("should return null for elements not a child of a scope", () { 11 test("should return null for elements not a child of a scope", () {
12 var doc = new Document(); 12 var doc = new Document();
13 var element = doc.createElement("div"); 13 var element = doc.createElement("div");
14 expect(element.ownerScope, isNull); 14 expect(element.owner, isNull);
15 }); 15 });
16 test("should return the document for elements in the document scope", () { 16 test("should return the document for elements in the document scope", () {
17 var doc = new Document(); 17 var doc = new Document();
18 var element = doc.createElement("div"); 18 var element = doc.createElement("div");
19 doc.appendChild(element); 19 doc.appendChild(element);
20 expect(element.ownerScope, equals(element.ownerDocument)); 20 expect(element.owner, equals(doc));
21 expect(element.ownerScope, equals(doc));
22 }); 21 });
23 test("should return the shadow root for elements in the shadow root scope", () { 22 test("should return the shadow root for elements in the shadow root scope", () {
24 var doc = new Document(); 23 var doc = new Document();
25 var host = doc.createElement("div"); 24 var host = doc.createElement("div");
26 var child = doc.createElement("div"); 25 var child = doc.createElement("div");
27 var shadowRoot = host.ensureShadowRoot(); 26 var shadowRoot = host.ensureShadowRoot();
28 shadowRoot.appendChild(child); 27 shadowRoot.appendChild(child);
29 expect(child.ownerScope, equals(shadowRoot)); 28 expect(child.owner, equals(shadowRoot));
30 }); 29 });
31 test("should return self for a shadow root or document", () { 30 test("should return self for a shadow root or document", () {
32 var doc = new Document(); 31 var doc = new Document();
33 var host = doc.createElement("div"); 32 var host = doc.createElement("div");
34 doc.appendChild(host); 33 doc.appendChild(host);
35 var shadowRoot = host.ensureShadowRoot(); 34 var shadowRoot = host.ensureShadowRoot();
36 expect(shadowRoot.ownerScope, equals(shadowRoot)); 35 expect(shadowRoot.owner, equals(shadowRoot));
37 expect(doc.ownerScope, equals(doc)); 36 expect(doc.owner, equals(doc));
38 }); 37 });
39 test("should dynamically update", () { 38 test("should dynamically update", () {
40 var doc = new Document(); 39 var doc = new Document();
41 var host = doc.createElement("div"); 40 var host = doc.createElement("div");
42 var child = doc.createElement("div"); 41 var child = doc.createElement("div");
43 var shadowRoot = host.ensureShadowRoot(); 42 var shadowRoot = host.ensureShadowRoot();
44 expect(child.ownerScope, isNull); 43 expect(child.owner, isNull);
45 shadowRoot.appendChild(child); 44 shadowRoot.appendChild(child);
46 expect(child.ownerScope, equals(shadowRoot)); 45 expect(child.owner, equals(shadowRoot));
47 child.remove(); 46 child.remove();
48 expect(child.ownerScope, isNull); 47 expect(child.owner, isNull);
49 }); 48 });
50 } 49 }
51 </script> 50 </script>
52 </sky> 51 </sky>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698