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

Unified Diff: LayoutTests/app_banner/app-banner-event-prompt.html

Issue 1214793002: Fix a memory leak in the app banner prompt layout tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase again Created 5 years, 5 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 | « LayoutTests/LeakExpectations ('k') | Source/modules/app_banner/BeforeInstallPromptEvent.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/app_banner/app-banner-event-prompt.html
diff --git a/LayoutTests/app_banner/app-banner-event-prompt.html b/LayoutTests/app_banner/app-banner-event-prompt.html
index b5edae164c381abd3475a70c2f4f61f631bfeee5..6fed8f7732e7561a74d68c7c4c8f3a9bcdc3d187 100644
--- a/LayoutTests/app_banner/app-banner-event-prompt.html
+++ b/LayoutTests/app_banner/app-banner-event-prompt.html
@@ -44,7 +44,7 @@ var prompt_test_cases = [
];
function verify_prompt_resolve(e, t) {
- e.prompt().then(function() { }, t.unreached_func("prompt() promise should resolve."));
+ e.prompt().then(undefined, t.unreached_func("prompt() promise should resolve."));
}
function verify_prompt_reject(e, t) {
@@ -75,30 +75,34 @@ function verify_userChoice(e, t, test_case, index) {
}), t.unreached_func("userChoice promise should resolve."));
}
+var events = []; // For storing the beforeinstallprompt event.
function prompt_test(index) {
if (index >= prompt_test_cases.length)
return;
var test_case = prompt_test_cases[index];
async_test(function(t) {
- var event = null;
var event_handler = t.step_func(function(e) {
// Remove the event handler to prevent it being used in subsequent
// invocations of prompt_test(). Save event object for call outside handler.
window.removeEventListener('beforeinstallprompt', event_handler);
- event = e;
assert_equals(e.platforms.length, 2, 'Number of platforms');
assert_equals(e.platforms[0], 'foo', 'First platform');
assert_equals(e.platforms[1], 'bar', 'Second platform');
+ if (test_case.cancel) {
+ e.preventDefault();
+ }
+
if (test_case.late) {
+ // Exit the handler once we've stopped the event.
+ events.push(e);
return;
}
if (test_case.cancel) {
- // Cancel the event, then call prompt() to restart the display pipeline.
- e.preventDefault();
+ // Call prompt() to restart the pipeline.
verify_prompt_resolve(e, t);
} else {
// A call to prompt() before preventDefault should reject.
@@ -117,14 +121,14 @@ function prompt_test(index) {
// Test that firing prompt() outside of the handler resolves or rejects correctly.
if (test_case.late) {
+ e = events.pop();
if (test_case.cancel) {
- event.preventDefault();
- verify_prompt_resolve(event, t);
+ verify_prompt_resolve(e, t);
} else {
- verify_prompt_reject(event, t);
+ verify_prompt_reject(e, t);
}
// Check userChoice and call the next test.
- verify_userChoice(event, t, test_case, index);
+ verify_userChoice(e, t, test_case, index);
}
}, test_case.name);
}
« no previous file with comments | « LayoutTests/LeakExpectations ('k') | Source/modules/app_banner/BeforeInstallPromptEvent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698