Skip to content

Commit

Permalink
[js] Asyncify UserPromptingChecker (#523)
Browse files Browse the repository at this point in the history
Refactor the UserPromptingChecker JavaScript class to use
"async"/"await", which greatly simplifies the asynchronous code in this
code.

This contributes to the JS modernization effort tracked by #264.
  • Loading branch information
emaxx-google authored Jan 26, 2022
1 parent 33e68db commit 470d4e9
Show file tree
Hide file tree
Showing 2 changed files with 171 additions and 160 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,8 @@ function getDialogMock(mockControl, mockedBehavior) {

/**
* Returns a negation of the given promise.
* @param {!goog.Promise} promise
* @return {!goog.Promise.<undefined>} A promise which is rejected when
* @param {!Promise} promise
* @return {!Promise.<undefined>} A promise which is rejected when
* |promise| gets resolved, and resolved (with no data) when |promise| is
* rejected.
*/
Expand All @@ -176,7 +176,7 @@ function negatePromise(promise) {
* @param {!MockedDialogBehavior} mockedDialogBehavior If |NOT_RUN|, then the
* GSC.PopupOpener.runModalDialog method is not expected to be called;
* otherwise, the called method will return the corresponding result.
* @param {function(!UserPromptingChecker):!goog.Promise} testCallback The test
* @param {function(!UserPromptingChecker):!Promise} testCallback The test
* function to be run after the needed setup; must return a promise of the test
* result.
* @return {function():!goog.Promise} The wrapped test function, which returns a
Expand Down Expand Up @@ -300,7 +300,7 @@ goog.exportSymbol(
null /* expectedStorageDataToBeWritten */,
MockedDialogBehavior.NOT_RUN /* mockedDialogBehavior */,
function(userPromptingChecker) {
return goog.Promise.all([
return Promise.all([
userPromptingChecker.check(FAKE_CLIENT_1_ORIGIN),
userPromptingChecker.check(FAKE_CLIENT_2_ORIGIN)
]);
Expand All @@ -318,7 +318,7 @@ goog.exportSymbol(
null /* expectedStorageDataToBeWritten */,
MockedDialogBehavior.NOT_RUN /* mockedDialogBehavior */,
function(userPromptingChecker) {
return goog.Promise.all([
return Promise.all([
userPromptingChecker.check(FAKE_CLIENT_1_ORIGIN),
userPromptingChecker.check(FAKE_CLIENT_2_ORIGIN)
]);
Expand Down
Loading

0 comments on commit 470d4e9

Please sign in to comment.