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

Side by Side Diff: chrome/test/data/webui/settings/test_util.js

Issue 2863213002: MD Settings: Fix and re-enable settings-main tests. (Closed)
Patch Set: Address comments. Created 3 years, 7 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
« no previous file with comments | « chrome/test/data/webui/settings/settings_main_test.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 cr.define('test_util', function() { 5 cr.define('test_util', function() {
6 /** 6 /**
7 * Observes an HTML attribute and fires a promise when it matches a given 7 * Observes an HTML attribute and fires a promise when it matches a given
8 * value. 8 * value.
9 * @param {!HTMLElement} target 9 * @param {!HTMLElement} target
10 * @param {string} attributeName 10 * @param {string} attributeName
11 * @param {*} attributeValue 11 * @param {*} attributeValue
12 * @return {!Promise} 12 * @return {!Promise}
13 */ 13 */
14 function whenAttributeIs(target, attributeName, attributeValue) { 14 function whenAttributeIs(target, attributeName, attributeValue) {
15 function isDone() { return target[attributeName] === attributeValue; } 15 function isDone() {
16 // TODO(dpapad): Following line should check for an attribute, not a
17 // property, meaning target.getAttribute(attributeName). Fix this and
18 // update callers to pass an attribute value instead.
19 return target[attributeName] === attributeValue;
20 }
16 21
17 return isDone() ? Promise.resolve() : new Promise(function(resolve) { 22 return isDone() ? Promise.resolve() : new Promise(function(resolve) {
18 new MutationObserver(function(mutations, observer) { 23 new MutationObserver(function(mutations, observer) {
19 for (var mutation of mutations) { 24 for (var mutation of mutations) {
20 assertEquals('attributes', mutation.type); 25 assertEquals('attributes', mutation.type);
21 if (mutation.attributeName == attributeName && isDone()) { 26 if (mutation.attributeName == attributeName && isDone()) {
22 observer.disconnect(); 27 observer.disconnect();
23 resolve(); 28 resolve();
24 return; 29 return;
25 } 30 }
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 el1.addEventListener(property + '-changed', forwardChange.bind(null, el2)); 65 el1.addEventListener(property + '-changed', forwardChange.bind(null, el2));
61 el2.addEventListener(property + '-changed', forwardChange.bind(null, el1)); 66 el2.addEventListener(property + '-changed', forwardChange.bind(null, el1));
62 } 67 }
63 68
64 return { 69 return {
65 eventToPromise: eventToPromise, 70 eventToPromise: eventToPromise,
66 fakeDataBind: fakeDataBind, 71 fakeDataBind: fakeDataBind,
67 whenAttributeIs: whenAttributeIs, 72 whenAttributeIs: whenAttributeIs,
68 }; 73 };
69 }); 74 });
OLDNEW
« no previous file with comments | « chrome/test/data/webui/settings/settings_main_test.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698