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

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

Issue 2341493003: MD Settings: Deflake attempt for CrSettingsPrivacyPageTest.PrivacyPage. (Closed)
Patch Set: Use MutationObserver, refactor. 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
Dan Beam 2016/09/15 18:17:08 nit: remove extra \n
dpapad 2016/09/15 18:52:12 Done.
6 cr.define('test_util', function() {
7 /**
8 * Observes an HTML attribute and fires a promise when it changes.
9 * @param {!HTMLElement} target
10 * @param {string} attributeName
11 * @return {!Promise}
12 */
13 function whenAttributeChanges(target, attributeName) {
Dan Beam 2016/09/15 18:17:08 whenAttributeIs(target, attributeName, attributeVa
dpapad 2016/09/15 18:52:12 Done.
14 return new Promise(function(resolve, reject) {
15 var observer = new MutationObserver(function(mutations) {
16 assertEquals(1, mutations.length);
17 assertEquals('attributes', mutations[0].type);
18 assertEquals(attributeName, mutations[0].attributeName);
19 observer.disconnect();
20 resolve();
21 });
22 observer.observe(
23 target, {attributes: true, childList: false, characterData: false});
24 });
25 }
26
27 /**
28 * Converts an event occurrence to a promise.
29 * @param {string} eventType
30 * @param {!HTMLElement} target
31 * @return {!Promise} A promise firing once the event occurs.
32 */
33 function eventToPromise(eventType, target) {
34 return new Promise(function(resolve, reject) {
35 target.addEventListener(eventType, resolve);
36 });
37 }
38
39 return {
40 eventToPromise: eventToPromise,
41 whenAttributeChanges: whenAttributeChanges,
42 };
43 });
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