Commit d136c816 authored by Shik Chen's avatar Shik Chen Committed by Commit Bot

[CCA] Add onAppWindowCreatedForTesting in background.

Use a callback instead of polling a boolean flag to notify the window
created event for test, because we might restart CCA when running a
test.

An alternative is to set the boolean flag to |false| in |onClosed|, but
that might hit a race condition if the app window is closed soon after
it's created, and before the |true| state is polled by test.

Bug: b:135905426
Test: Restart CCA 200 times in Tast.
Change-Id: Ia29e0221d072845b23e4598ca2d594330b3b1ac0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1672827Reviewed-by: default avatarSheng-hao Tsao <shenghao@chromium.org>
Commit-Queue: Shik Chen <shik@chromium.org>
Cr-Commit-Position: refs/heads/master@{#672787}
parent 4cecc3e6
......@@ -40,9 +40,17 @@ cca.bg.TOPBAR_COLOR = '#000000';
* won't connect to the main.html target before the window is created, otherwise
* the window might disappear.
* @type {boolean}
* @deprecated This flag would be removed after we migrate CCA Tast tests.
*/
cca.bg.appWindowCreated = false;
/**
* It's used in test to ensure that we won't connect to the main.html target
* before the window is created, otherwise the window might disappear.
* @type {?function(): undefined}
*/
cca.bg.onAppWindowCreatedForTesting = null;
/**
* Creates the window. Note, that only one window at once is supported.
*/
......@@ -82,6 +90,9 @@ cca.bg.create = function() {
chrome.storage.local.set({fullscreen: inAppWindow.isFullscreen()});
});
cca.bg.appWindowCreated = true;
if (cca.bg.onAppWindowCreatedForTesting !== null) {
cca.bg.onAppWindowCreatedForTesting();
}
});
});
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment