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

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

Issue 2341493003: MD Settings: Deflake attempt for CrSettingsPrivacyPageTest.PrivacyPage. (Closed)
Patch Set: Check for specific value. Created 4 years, 3 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/privacy_page_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
(Empty)
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
3 // found in the LICENSE file.
4
5 cr.define('test_util', function() {
6 /**
7 * Observes an HTML attribute and fires a promise when it matches a given
8 * value.
9 * @param {!HTMLElement} target
10 * @param {string} attributeName
11 * @param {*} attributeValue
12 * @return {!Promise}
13 */
14 function whenAttributeIs(target, attributeName, attributeValue) {
15 function isDone() { return target[attributeName] === attributeValue; }
16
17 return isDone() ? Promise.resolve() : new Promise(function(resolve) {
18 new MutationObserver(function(mutations, observer) {
19 for (var mutation of mutations) {
20 assertEquals('attributes', mutation.type);
21 if (mutation.attributeName == attributeName && isDone()) {
22 observer.disconnect();
23 resolve();
24 return;
25 }
26 }
27 }).observe(
28 target, {attributes: true, childList: false, characterData: false});
29 });
30 }
31
32 /**
33 * Converts an event occurrence to a promise.
34 * @param {string} eventType
35 * @param {!HTMLElement} target
36 * @return {!Promise} A promise firing once the event occurs.
37 */
38 function eventToPromise(eventType, target) {
39 return new Promise(function(resolve, reject) {
40 target.addEventListener(eventType, resolve);
41 });
42 }
43
44 return {
45 eventToPromise: eventToPromise,
46 whenAttributeIs: whenAttributeIs,
47 };
48 });
OLDNEW
« no previous file with comments | « chrome/test/data/webui/settings/privacy_page_test.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698