OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 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 onload = function() { | |
6 debug = true; | |
7 var getURL = chrome.extension.getURL; | |
8 var URL_MAIN = getURL('main.html'); | |
9 var URL_FRAME1 = 'http://a.com:PORT/extensions/api_test/webnavigation/' + | |
10 'crossProcessIframe/frame.html'; | |
11 var URL_FRAME2 = 'http://b.com:PORT/extensions/api_test/webnavigation/' + | |
12 'crossProcessIframe/frame.html'; | |
13 var URL_FRAME3 = 'http://c.com:PORT/extensions/api_test/webnavigation/' + | |
14 'crossProcessIframe/frame.html'; | |
15 chrome.tabs.create({'url': 'about:blank'}, function(tab) { | |
16 var tabId = tab.id; | |
17 chrome.test.getConfig(function(config) { | |
18 var fixPort = function(url) { | |
19 return url.replace(/PORT/g, config.testServer.port); | |
20 }; | |
21 URL_FRAME1 = fixPort(URL_FRAME1); | |
22 URL_FRAME2 = fixPort(URL_FRAME2); | |
23 URL_FRAME3 = fixPort(URL_FRAME3); | |
24 | |
25 chrome.test.runTests([ | |
26 // Navigates from an extension page to a HTTP page which causes a | |
27 // process switch. The extension page embeds a same-process iframe which | |
28 // embeds another frame navigates three times (cross-process): | |
nasko
2015/12/09 23:06:09
nit: "frame that navigates"?
robwu
2015/12/10 00:00:50
Done.
| |
29 // c. Loaded by the parent frame. | |
30 // d. Navigated by the parent frame. | |
31 // e. Navigated by the child frame. | |
32 // Tests whether the frameId stays constant across navigations. | |
33 function crossProcessIframe() { | |
34 expect([ | |
35 { label: 'main-onBeforeNavigate', | |
36 event: 'onBeforeNavigate', | |
37 details: { frameId: 0, | |
38 parentFrameId: -1, | |
39 processId: 0, | |
40 tabId: 0, | |
41 timeStamp: 0, | |
42 url: URL_MAIN }}, | |
43 { label: 'main-onCommitted', | |
44 event: 'onCommitted', | |
45 details: { frameId: 0, | |
46 processId: 0, | |
47 tabId: 0, | |
48 timeStamp: 0, | |
49 transitionQualifiers: [], | |
50 transitionType: 'link', | |
51 url: URL_MAIN }}, | |
52 { label: 'main-onDOMContentLoaded', | |
53 event: 'onDOMContentLoaded', | |
54 details: { frameId: 0, | |
55 processId: 0, | |
56 tabId: 0, | |
57 timeStamp: 0, | |
58 url: URL_MAIN }}, | |
59 { label: 'main-onCompleted', | |
60 event: 'onCompleted', | |
61 details: { frameId: 0, | |
62 processId: 0, | |
63 tabId: 0, | |
64 timeStamp: 0, | |
65 url: URL_MAIN }}, | |
66 // pre-a.com is the navigation before the process swap. | |
67 { label: 'pre-a.com-onBeforeNavigate', | |
68 event: 'onBeforeNavigate', | |
69 details: { frameId: 1, | |
70 parentFrameId: 0, | |
71 processId: 0, | |
72 tabId: 0, | |
73 timeStamp: 0, | |
74 url: URL_FRAME1 }}, | |
75 { label: 'pre-a.com-onErrorOccurred', | |
76 event: 'onErrorOccurred', | |
77 details: { error: 'net::ERR_ABORTED', | |
78 frameId: 1, | |
79 processId: 0, | |
80 tabId: 0, | |
81 timeStamp: 0, | |
82 url: URL_FRAME1 }}, | |
83 { label: 'a.com-onBeforeNavigate', | |
84 event: 'onBeforeNavigate', | |
85 details: { frameId: 1, | |
86 parentFrameId: 0, | |
87 processId: 1, | |
88 tabId: 0, | |
89 timeStamp: 0, | |
90 url: URL_FRAME1 }}, | |
91 { label: 'a.com-onCommitted', | |
92 event: 'onCommitted', | |
93 details: { frameId: 1, | |
94 processId: 1, | |
95 tabId: 0, | |
96 timeStamp: 0, | |
97 transitionQualifiers: [], | |
98 transitionType: 'auto_subframe', | |
99 url: URL_FRAME1 }}, | |
100 { label: 'a.com-onDOMContentLoaded', | |
101 event: 'onDOMContentLoaded', | |
102 details: { frameId: 1, | |
103 processId: 1, | |
104 tabId: 0, | |
105 timeStamp: 0, | |
106 url: URL_FRAME1 }}, | |
107 { label: 'a.com-onCompleted', | |
108 event: 'onCompleted', | |
109 details: { frameId: 1, | |
110 processId: 1, | |
111 tabId: 0, | |
112 timeStamp: 0, | |
113 url: URL_FRAME1 }}, | |
114 // There is no onBeforeNavigate and onErrorOccurred (like the other | |
115 // navigations in this test) because this navigation is triggered by | |
116 // a frame in a different process, so the navigation directly goes | |
117 // through the browser. This difference will be resolved once | |
118 // PlzNavigate goes live. | |
119 { label: 'b.com-onBeforeNavigate', | |
120 event: 'onBeforeNavigate', | |
121 details: { frameId: 1, | |
122 parentFrameId: 0, | |
123 processId: 2, | |
124 tabId: 0, | |
125 timeStamp: 0, | |
126 url: URL_FRAME2 }}, | |
127 { label: 'b.com-onCommitted', | |
128 event: 'onCommitted', | |
129 details: { frameId: 1, | |
130 processId: 2, | |
131 tabId: 0, | |
132 timeStamp: 0, | |
133 transitionQualifiers: [], | |
134 transitionType: 'manual_subframe', | |
135 url: URL_FRAME2 }}, | |
136 { label: 'b.com-onDOMContentLoaded', | |
137 event: 'onDOMContentLoaded', | |
138 details: { frameId: 1, | |
139 processId: 2, | |
140 tabId: 0, | |
141 timeStamp: 0, | |
142 url: URL_FRAME2 }}, | |
143 { label: 'b.com-onCompleted', | |
144 event: 'onCompleted', | |
145 details: { frameId: 1, | |
146 processId: 2, | |
147 tabId: 0, | |
148 timeStamp: 0, | |
149 url: URL_FRAME2 }}, | |
150 // pre-c.com is the navigation before the process swap. | |
151 { label: 'pre-c.com-onBeforeNavigate', | |
152 event: 'onBeforeNavigate', | |
153 details: { frameId: 1, | |
154 parentFrameId: 0, | |
155 processId: 2, | |
156 tabId: 0, | |
157 timeStamp: 0, | |
158 url: URL_FRAME3 }}, | |
159 { label: 'pre-c.com-onErrorOccurred', | |
160 event: 'onErrorOccurred', | |
161 details: { error: 'net::ERR_ABORTED', | |
162 frameId: 1, | |
163 processId: 2, | |
164 tabId: 0, | |
165 timeStamp: 0, | |
166 url: URL_FRAME3 }}, | |
167 { label: 'c.com-onBeforeNavigate', | |
168 event: 'onBeforeNavigate', | |
169 details: { frameId: 1, | |
170 parentFrameId: 0, | |
171 processId: 3, | |
172 tabId: 0, | |
173 timeStamp: 0, | |
174 url: URL_FRAME3 }}, | |
175 { label: 'c.com-onCommitted', | |
176 event: 'onCommitted', | |
177 details: { frameId: 1, | |
178 processId: 3, | |
179 tabId: 0, | |
180 timeStamp: 0, | |
181 transitionQualifiers: [], | |
182 transitionType: 'manual_subframe', | |
183 url: URL_FRAME3 }}, | |
184 { label: 'c.com-onDOMContentLoaded', | |
185 event: 'onDOMContentLoaded', | |
186 details: { frameId: 1, | |
187 processId: 3, | |
188 tabId: 0, | |
189 timeStamp: 0, | |
190 url: URL_FRAME3 }}, | |
191 { label: 'c.com-onCompleted', | |
192 event: 'onCompleted', | |
193 details: { frameId: 1, | |
194 processId: 3, | |
195 tabId: 0, | |
196 timeStamp: 0, | |
197 url: URL_FRAME3 }}], | |
198 [ | |
199 navigationOrder('main-'), | |
200 navigationOrder('a.com-'), | |
201 navigationOrder('b.com-'), | |
202 navigationOrder('c.com-'), | |
203 ['pre-a.com-onBeforeNavigate', 'pre-a.com-onErrorOccurred'], | |
nasko
2015/12/09 23:06:09
Don't we want to ensure that pre-a.com-onErrorOccu
robwu
2015/12/10 00:00:50
That's what I want as well, but unfortunately the
nasko
2015/12/17 01:19:48
I can see why that is, even though I'm not happy a
| |
204 ['pre-c.com-onBeforeNavigate', 'pre-c.com-onErrorOccurred']]); | |
205 | |
206 chrome.tabs.update(tabId, { | |
207 url: URL_MAIN + '?' + config.testServer.port | |
208 }); | |
209 }, | |
210 | |
211 ]); | |
212 }); | |
213 }); | |
214 }; | |
OLD | NEW |