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

Unified Diff: chrome/test/data/extensions/api_test/webrequest/test_unload2.js

Issue 2003593002: Add tests for webRequest events and frame unload (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: battre's nits Created 4 years, 7 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
Index: chrome/test/data/extensions/api_test/webrequest/test_unload2.js
diff --git a/chrome/test/data/extensions/api_test/webrequest/test_unload2.js b/chrome/test/data/extensions/api_test/webrequest/test_unload2.js
new file mode 100644
index 0000000000000000000000000000000000000000..5d9a3deba2fd6a7b4aae250f23c030e5b2f487ff
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/webrequest/test_unload2.js
@@ -0,0 +1,53 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+runTests([
+ // Load a slow page in a tab and close it.
+ function loadSlowTabAndClose() {
+ const url = getSlowURL('slow-single-main-frame');
+
+ expect([
+ { label: 'onBeforeRequest',
+ event: 'onBeforeRequest',
+ details: {
+ type: 'main_frame',
+ url,
+ frameUrl: url,
+ }
+ },
+ { label: 'onBeforeSendHeaders',
+ event: 'onBeforeSendHeaders',
+ details: {
+ type: 'main_frame',
+ url,
+ },
+ },
+ { label: 'onSendHeaders',
+ event: 'onSendHeaders',
+ details: {
+ type: 'main_frame',
+ url,
+ },
+ },
+ { label: 'onErrorOccurred',
+ event: 'onErrorOccurred',
+ details: {
+ type: 'main_frame',
+ url,
+ fromCache: false,
+ error: 'net::ERR_ABORTED',
+ },
+ }],
+ [['onBeforeRequest', 'onBeforeSendHeaders', 'onSendHeaders',
+ 'onErrorOccurred']]);
+
+ var callbackDone = chrome.test.callbackAdded();
+
+ waitUntilSendHeaders('main_frame', url, function() {
+ // Cancels load and triggers onErrorOccurred.
+ chrome.tabs.remove(tabId, callbackDone);
+ }),
+ chrome.tabs.update(tabId, {url});
+ },
+]);

Powered by Google App Engine
This is Rietveld 408576698