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

Unified Diff: sky/tests/mutation-observer/observe-characterdata.html

Issue 685623002: Move the tests from .html to .sky (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: sky/tests/mutation-observer/observe-characterdata.html
diff --git a/sky/tests/mutation-observer/observe-characterdata.html b/sky/tests/mutation-observer/observe-characterdata.html
deleted file mode 100644
index c686e3b91d6f4900bd7c8481e43bc9e4b13cf8cb..0000000000000000000000000000000000000000
--- a/sky/tests/mutation-observer/observe-characterdata.html
+++ /dev/null
@@ -1,229 +0,0 @@
-<html>
-<link rel="import" href="../resources/chai.html" />
-<link rel="import" href="../resources/mocha.html" />
-<body id="body">
-<script>
-document.body = document.getElementById("body");
-
-describe('MutationObserver on character data', function() {
- it('should handle basic aspects of characterData observation', function(done) {
- var observer;
- var mutations;
- var charDataNode;
-
- function start() {
- var div = document.createElement('div');
- div.textContent = 'foo';
- charDataNode = div.firstChild;
- observer = new MutationObserver(function(records) {
- mutations = records;
- });
-
- observer.observe(charDataNode, {characterData: true});
- charDataNode.textContent = 'bar';
- setTimeout(checkDisconnectAndMutate, 0);
- }
-
- function checkDisconnectAndMutate() {
- // ...can characterData changes be observed at all
-
- assert.equal(mutations.length, 1);
- assert.equal(mutations[0].type, "characterData");
- assert.equal(mutations[0].target, charDataNode);
-
- mutations = null;
- observer.disconnect();
- charDataNode.textContent = 'baz';
- setTimeout(checkNotDeliveredAndMutateMultiple, 0);
- }
-
- function checkNotDeliveredAndMutateMultiple() {
- // ...observer.disconnect() should prevent further delivery of mutations.
-
- assert.equal(mutations, null);
- charDataNode = document.createTextNode('');
- observer.observe(charDataNode, { characterData: true });
- charDataNode.textContent = 'foo';
- charDataNode.textContent = 'bar';
- setTimeout(finish);
- }
-
- function finish() {
- // ...re-observing after disconnect works with the same observer.
-
- assert.equal(mutations.length, 2);
- assert.equal(mutations[0].type, "characterData");
- assert.equal(mutations[0].target, charDataNode);
- assert.equal(mutations[1].type, "characterData");
- assert.equal(mutations[1].target, charDataNode);
- observer.disconnect();
- done();
- }
-
- start();
- });
-
- it('should only notify of characterData changes when requested', function(done) {
- var observer;
- var mutations;
-
- function start() {
- var div = document.createElement('div');
- div.textContent = 'hello';
- var charDataNode = div.firstChild;
- observer = new MutationObserver(function(records) {
- mutations = records;
- });
-
- observer.observe(charDataNode, {childList: true, attributes: true});
- charDataNode = 'goodbye';
- setTimeout(finish, 0);
- }
-
- function finish() {
- assert.equal(mutations, null);
- observer.disconnect();
- done();
- }
-
- start();
- });
-
- it('should allow multiple observers can be registered to a given node and both receive mutations', function(done) {
- var observer;
- var observer2;
- var charDataNode;
- var mutations;
- var mutations2;
-
- function start() {
- var div = document.createElement('div');
- div.textContent = 'foo';
- charDataNode = div.firstChild;
- observer = new MutationObserver(function(records) {
- mutations = records;
- });
- observer2 = new MutationObserver(function(records) {
- mutations2 = records;
- });
- observer.observe(charDataNode, {characterData: true});
- observer2.observe(charDataNode, {characterData: true});
- charDataNode.textContent = 'bar';
- setTimeout(finish, 0);
- }
-
- function finish() {
- assert.equal(mutations.length, 1);
- assert.equal(mutations[0].type, "characterData");
- assert.equal(mutations[0].target, charDataNode);
- assert.equal(mutations2.length, 1);
- assert.equal(mutations2[0].type, "characterData");
- assert.equal(mutations2[0].target, charDataNode);
- observer.disconnect();
- observer2.disconnect();
- done();
- }
-
- start();
- });
-
- it('should provide oldValue is returned when requested', function(done) {
- var observer;
- var mutations;
- var charDataNode;
-
- function start() {
- var div = document.createElement('div');
- div.textContent = 'foo';
- charDataNode = div.firstChild;
- observer = new MutationObserver(function(records) {
- mutations = records;
- });
- observer.observe(charDataNode, {characterData: true, characterDataOldValue: true});
- charDataNode.textContent = 'bar';
- charDataNode.textContent = 'baz';
- setTimeout(finish, 0);
- }
-
- function finish() {
- assert.equal(mutations.length, 2);
- assert.equal(mutations[0].type, "characterData");
- assert.equal(mutations[0].target, charDataNode);
- assert.equal(mutations[0].oldValue, "foo");
- assert.equal(mutations[1].type, "characterData");
- assert.equal(mutations[1].target, charDataNode);
- assert.equal(mutations[1].oldValue, "bar");
- observer.disconnect();
- done();
- }
-
- start();
- });
-
- it('should allow observing both with and without oldValue', function(done) {
- var observerWithOldValue;
- var observer;
- var mutations;
- var mutationsWithOldValue;
-
- function start() {
- var div = document.createElement('div');
- div.textContent = 'foo';
- var charDataNode = div.firstChild;
- observerWithOldValue = new MutationObserver(function(records) {
- mutationsWithOldValue = records;
- });
- observer = new MutationObserver(function(records) {
- mutations = records;
- });
- observerWithOldValue.observe(charDataNode, {characterData: true, characterDataOldValue: true});
- observer.observe(charDataNode, {characterData: true});
- charDataNode.textContent = 'bar';
- setTimeout(finish, 0);
- }
-
- function finish() {
- assert.equal(mutationsWithOldValue.length, 1);
- assert.equal(mutationsWithOldValue[0].type, "characterData");
- assert.equal(mutationsWithOldValue[0].oldValue, "foo");
- assert.equal(mutations.length, 1);
- assert.equal(mutations[0].type, "characterData");
- assert.equal(mutations[0].oldValue, null);
- observerWithOldValue.disconnect();
- observer.disconnect();
- done();
- }
-
- start();
- });
-
- it('should provide oldValue if any observation requests it', function(done) {
- var observer;
- var mutations;
-
- function start() {
- var div = document.createElement('div');
- div.textContent = 'foo';
- var charDataNode = div.firstChild;
- observer = new MutationObserver(function(records) {
- mutations = records;
- });
- observer.observe(div, {characterData: true, characterDataOldValue: true, subtree: true});
- observer.observe(charDataNode, {characterData: true});
- charDataNode.textContent = 'bar';
- setTimeout(finish, 0);
- }
-
- function finish() {
- assert.equal(mutations.length, 1);
- assert.equal(mutations[0].type, "characterData");
- assert.equal(mutations[0].oldValue, "foo");
- observer.disconnect();
- done();
- }
-
- start();
- });
-});
-</script>
-</html>
« no previous file with comments | « sky/tests/mutation-observer/observe-attributes.sky ('k') | sky/tests/mutation-observer/observe-characterdata.sky » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698