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

Side by Side Diff: chrome/test/data/extensions/api_test/webrequest/test_unload3.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, 6 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 runTests([
6 // Open a page that loads a slow same-origin frame in it and remove the frame.
7 function loadTabWithSlowFrameAndRemoveFrame() {
8 const hostname = 'slow-child-frame-same-origin-remove-frame';
9 const url = getSlowURL(hostname);
10 const mainUrl = getPageWithFrame(url, hostname);
11
12 expect([
13 { label: 'onBeforeRequest',
14 event: 'onBeforeRequest',
15 details: {
16 type: 'sub_frame',
17 url,
18 frameId: 1,
19 parentFrameId: 0,
20 frameUrl: url,
21 }
22 },
23 { label: 'onBeforeSendHeaders',
24 event: 'onBeforeSendHeaders',
25 details: {
26 type: 'sub_frame',
27 url,
28 frameId: 1,
29 parentFrameId: 0,
30 },
31 },
32 { label: 'onSendHeaders',
33 event: 'onSendHeaders',
34 details: {
35 type: 'sub_frame',
36 url,
37 frameId: 1,
38 parentFrameId: 0,
39 },
40 },
41 { label: 'onErrorOccurred',
42 event: 'onErrorOccurred',
43 details: {
44 type: 'sub_frame',
45 url,
46 frameId: 1,
47 parentFrameId: 0,
48 fromCache: false,
49 error: 'net::ERR_ABORTED',
50 },
51 }],
52 [['onBeforeRequest', 'onBeforeSendHeaders', 'onSendHeaders',
53 'onErrorOccurred']],
54 {
55 urls: ['<all_urls>'],
56 types: ['sub_frame'],
57 });
58
59 waitUntilSendHeaders('sub_frame', url, function() {
60 // Cancels load and triggers onErrorOccurred.
61 chrome.tabs.executeScript(tabId, {
62 code: 'document.querySelector("iframe").remove();',
63 });
64 });
65 chrome.tabs.update(tabId, {url: mainUrl});
66 },
67
68 // Now reload the page (so that the frame appears again) and remove the tab.
69 // The expectations are identical to the previous test.
70 function openTabWithSlowFrameAndRemoveTab() {
71 const hostname = 'slow-child-frame-same-origin-remove-tab';
72 const url = getSlowURL(hostname);
73 const mainUrl = getPageWithFrame(url, hostname);
74
75 expect([
76 { label: 'onBeforeRequest',
77 event: 'onBeforeRequest',
78 details: {
79 type: 'sub_frame',
80 url,
81 frameId: 1,
82 parentFrameId: 0,
83 frameUrl: url,
84 }
85 },
86 { label: 'onBeforeSendHeaders',
87 event: 'onBeforeSendHeaders',
88 details: {
89 type: 'sub_frame',
90 url,
91 frameId: 1,
92 parentFrameId: 0,
93 },
94 },
95 { label: 'onSendHeaders',
96 event: 'onSendHeaders',
97 details: {
98 type: 'sub_frame',
99 url,
100 frameId: 1,
101 parentFrameId: 0,
102 },
103 },
104 { label: 'onErrorOccurred',
105 event: 'onErrorOccurred',
106 details: {
107 type: 'sub_frame',
108 url,
109 frameId: 1,
110 parentFrameId: 0,
111 fromCache: false,
112 error: 'net::ERR_ABORTED',
113 },
114 }],
115 [['onBeforeRequest', 'onBeforeSendHeaders', 'onSendHeaders',
116 'onErrorOccurred']],
117 {
118 urls: ['<all_urls>'],
119 types: ['sub_frame'],
120 });
121
122 var callbackDone = chrome.test.callbackAdded();
123
124 waitUntilSendHeaders('sub_frame', url, function() {
125 // Cancels load and triggers onErrorOccurred.
126 chrome.tabs.remove(tabId, callbackDone);
127 });
128 chrome.tabs.update(tabId, {url: mainUrl});
129 },
130 ]);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698