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

Unified Diff: remoting/webapp/browser_test/timeout_waiter.js

Issue 838543002: Implement browser test for It2Me (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix merge conflicts Created 5 years, 11 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
« no previous file with comments | « remoting/webapp/browser_test/it2me_browser_test.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/webapp/browser_test/timeout_waiter.js
diff --git a/remoting/webapp/browser_test/timeout_waiter.js b/remoting/webapp/browser_test/timeout_waiter.js
index c858806f49638f4d47a61c1adeabafd5d95188fe..2bb7e70eb4cf4f4d0b357bc313ac9eae156e3f4a 100644
--- a/remoting/webapp/browser_test/timeout_waiter.js
+++ b/remoting/webapp/browser_test/timeout_waiter.js
@@ -34,16 +34,22 @@ browserTest.Predicate.prototype.description = function() {};
* @return {Promise}
*/
browserTest.waitFor = function(predicate, opt_timeout) {
- return new Promise(function(fulfill, reject) {
+ /**
+ * @param {function():void} fulfill
+ * @param {function(Error):void} reject
+ */
+ return new Promise(function (fulfill, reject) {
if (opt_timeout === undefined) {
opt_timeout = browserTest.Timeout.DEFAULT;
}
- var end = Number(new Date()) + opt_timeout;
+
+ var timeout = /** @type {number} */ opt_timeout;
+ var end = Number(Date.now()) + timeout;
var testPredicate = function() {
if (predicate.evaluate()) {
console.log(predicate.description() + ' satisfied.');
fulfill();
- } else if (Number(new Date()) >= end) {
+ } else if (Date.now() >= end) {
reject(new Error('Timed out (' + opt_timeout + 'ms) waiting for ' +
predicate.description()));
} else {
@@ -56,15 +62,18 @@ browserTest.waitFor = function(predicate, opt_timeout) {
};
/**
+ * @suppress {checkTypes}
* @param {string} id
* @return {browserTest.Predicate}
*/
browserTest.isVisible = function(id) {
- var element = document.getElementById(id);
- browserTest.expect(element, 'No such element: ' + id);
+ /** @type {browserTest.Predicate} */
return {
evaluate: function() {
- return element.getBoundingClientRect().width != 0;
+ /** @type {HTMLElement} */
+ var element = document.getElementById(id);
+ browserTest.expect(Boolean(element), 'No such element: ' + id);
+ return element.getBoundingClientRect().width !== 0;
},
description: function() {
return 'isVisible(' + id + ')';
@@ -73,14 +82,18 @@ browserTest.isVisible = function(id) {
};
/**
+ * @suppress {checkTypes}
* @param {string} id
* @return {browserTest.Predicate}
*/
browserTest.isEnabled = function(id) {
- var element = document.getElementById(id);
- browserTest.expect(element, 'No such element: ' + id);
+
+ /** @type {browserTest.Predicate} */
return {
evaluate: function() {
+ /** @type {HTMLElement} */
+ var element = document.getElementById(id);
+ browserTest.expect(Boolean(element), 'No such element: ' + id);
return !element.disabled;
},
description: function() {
@@ -88,3 +101,4 @@ browserTest.isEnabled = function(id) {
}
};
};
+
« no previous file with comments | « remoting/webapp/browser_test/it2me_browser_test.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698