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

Unified Diff: sky/tests/dom/ownerScope.sky

Issue 810793005: Implement Node.ownerScope (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Update to spec. Created 6 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/engine/core/dom/Node.idl ('k') | sky/tests/dom/ownerScope-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/tests/dom/ownerScope.sky
diff --git a/sky/tests/dom/ownerScope.sky b/sky/tests/dom/ownerScope.sky
new file mode 100644
index 0000000000000000000000000000000000000000..5eb7a8ec96efaaad5a99438f586bbb1e07e44518
--- /dev/null
+++ b/sky/tests/dom/ownerScope.sky
@@ -0,0 +1,47 @@
+<sky>
+<import src="../resources/chai.sky" />
+<import src="../resources/mocha.sky" />
+<script>
+describe("ownerScope", function() {
+ it("should return null for elements not a child of a scope", function() {
+ var doc = new Document();
+ var element = doc.createElement("div");
+ assert.isNull(element.ownerScope);
+ });
+ it("should return the document for elements in the document scope", function() {
+ var doc = new Document();
+ var element = doc.createElement("div");
+ doc.appendChild(element);
+ assert.equal(element.ownerScope, element.ownerDocument);
+ assert.equal(element.ownerScope, doc);
+ });
+ it("should return the shadow root for elements in the shadow root scope", function() {
+ var doc = new Document();
+ var host = doc.createElement("div");
+ var child = doc.createElement("div");
+ var shadowRoot = host.ensureShadowRoot();
+ shadowRoot.appendChild(child);
+ assert.equal(child.ownerScope, shadowRoot);
+ });
+ it("should return self for a shadow root or document", function() {
+ var doc = new Document();
+ var host = doc.createElement("div");
+ doc.appendChild(host);
+ var shadowRoot = host.ensureShadowRoot();
+ assert.equal(shadowRoot.ownerScope, shadowRoot);
+ assert.equal(doc.ownerScope, doc);
+ });
+ it("should dynamically update", function() {
+ var doc = new Document();
+ var host = doc.createElement("div");
+ var child = doc.createElement("div");
+ var shadowRoot = host.ensureShadowRoot();
+ assert.equal(child.ownerScope, null);
+ shadowRoot.appendChild(child);
+ assert.equal(child.ownerScope, shadowRoot);
+ child.remove();
+ assert.equal(child.ownerScope, null);
+ });
+});
+</script>
+</sky>
« no previous file with comments | « sky/engine/core/dom/Node.idl ('k') | sky/tests/dom/ownerScope-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698