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): | |
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: "a-onBeforeNavigate", | |
nasko
2015/11/06 23:28:27
Shouldn't we use "main-" prefix on these, as we al
| |
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: "a-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: "a-onDOMContentLoaded", | |
53 event: "onDOMContentLoaded", | |
54 details: { frameId: 0, | |
55 processId: 0, | |
56 tabId: 0, | |
57 timeStamp: 0, | |
58 url: URL_MAIN }}, | |
59 { label: "a-onCompleted", | |
60 event: "onCompleted", | |
61 details: { frameId: 0, | |
62 processId: 0, | |
63 tabId: 0, | |
64 timeStamp: 0, | |
65 url: URL_MAIN }}, | |
66 // Process swap. | |
nasko
2015/11/06 23:28:27
Here I would expect to see the load of the iframe
| |
67 { label: "pre-b-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-b-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: "b-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: "b-onCommitted", | |
92 event: "onCommitted", | |
93 details: { frameId: 1, | |
94 processId: 1, | |
95 tabId: 0, | |
96 timeStamp: 0, | |
97 transitionQualifiers: [], | |
98 transitionType: "auto_subframe", | |
nasko
2015/11/06 23:28:27
Hmm, this isn't quite expected for me. auto_subfra
| |
99 url: URL_FRAME1 }}, | |
100 { label: "b-onDOMContentLoaded", | |
101 event: "onDOMContentLoaded", | |
102 details: { frameId: 1, | |
103 processId: 1, | |
104 tabId: 0, | |
105 timeStamp: 0, | |
106 url: URL_FRAME1 }}, | |
107 { label: "b-onCompleted", | |
108 event: "onCompleted", | |
109 details: { frameId: 1, | |
110 processId: 1, | |
111 tabId: 0, | |
112 timeStamp: 0, | |
113 url: URL_FRAME1 }}, | |
114 // TODO(robwu): Why is there no onBeforeNavigate and onErrorOccurred | |
115 // like above before the process swap? | |
nasko
2015/11/06 23:28:27
When you are on b.com, it registers an onload even
robwu
2015/11/07 00:23:40
By "like above", I'm referring to the pair of onBe
| |
116 { label: "c-onBeforeNavigate", | |
117 event: "onBeforeNavigate", | |
118 details: { frameId: 1, | |
119 parentFrameId: 0, | |
120 processId: 2, | |
nasko
2015/11/06 23:28:27
Does this pass? I would expect the onBeforeNavigat
robwu
2015/11/07 00:23:40
The test passes. My TODO comment a few lines back
| |
121 tabId: 0, | |
122 timeStamp: 0, | |
123 url: URL_FRAME2 }}, | |
124 { label: "c-onCommitted", | |
125 event: "onCommitted", | |
126 details: { frameId: 1, | |
127 processId: 2, | |
128 tabId: 0, | |
129 timeStamp: 0, | |
130 transitionQualifiers: [], | |
131 transitionType: "manual_subframe", | |
132 url: URL_FRAME2 }}, | |
133 { label: "c-onDOMContentLoaded", | |
134 event: "onDOMContentLoaded", | |
135 details: { frameId: 1, | |
136 processId: 2, | |
137 tabId: 0, | |
138 timeStamp: 0, | |
139 url: URL_FRAME2 }}, | |
140 { label: "c-onCompleted", | |
141 event: "onCompleted", | |
142 details: { frameId: 1, | |
143 processId: 2, | |
144 tabId: 0, | |
145 timeStamp: 0, | |
146 url: URL_FRAME2 }}, | |
147 // Process swap. | |
148 { label: "pre-d-onBeforeNavigate", | |
nasko
2015/11/06 23:28:27
Urgh, I might have been misreading these steps bec
robwu
2015/12/07 23:44:22
Done.
| |
149 event: "onBeforeNavigate", | |
150 details: { frameId: 1, | |
151 parentFrameId: 0, | |
152 processId: 2, | |
153 tabId: 0, | |
154 timeStamp: 0, | |
155 url: URL_FRAME3 }}, | |
156 { label: "pre-d-onErrorOccurred", | |
157 event: "onErrorOccurred", | |
158 details: { error: "net::ERR_ABORTED", | |
159 frameId: 1, | |
160 processId: 2, | |
161 tabId: 0, | |
162 timeStamp: 0, | |
163 url: URL_FRAME3 }}, | |
164 { label: "d-onBeforeNavigate", | |
165 event: "onBeforeNavigate", | |
166 details: { frameId: 1, | |
167 parentFrameId: 0, | |
168 processId: 3, | |
169 tabId: 0, | |
170 timeStamp: 0, | |
171 url: URL_FRAME3 }}, | |
172 { label: "d-onCommitted", | |
173 event: "onCommitted", | |
174 details: { frameId: 1, | |
175 processId: 3, | |
176 tabId: 0, | |
177 timeStamp: 0, | |
178 transitionQualifiers: [], | |
179 transitionType: "manual_subframe", | |
180 url: URL_FRAME3 }}, | |
181 { label: "d-onDOMContentLoaded", | |
182 event: "onDOMContentLoaded", | |
183 details: { frameId: 1, | |
184 processId: 3, | |
185 tabId: 0, | |
186 timeStamp: 0, | |
187 url: URL_FRAME3 }}, | |
188 { label: "d-onCompleted", | |
189 event: "onCompleted", | |
190 details: { frameId: 1, | |
191 processId: 3, | |
192 tabId: 0, | |
193 timeStamp: 0, | |
194 url: URL_FRAME3 }}], | |
195 [ | |
196 navigationOrder("a-"), | |
197 navigationOrder("b-"), | |
198 navigationOrder("c-"), | |
199 navigationOrder("d-"), | |
200 ["pre-b-onBeforeNavigate", "pre-b-onErrorOccurred"], | |
201 ["pre-d-onBeforeNavigate", "pre-d-onErrorOccurred"]]); | |
202 | |
203 chrome.tabs.update(tabId, { | |
204 url: URL_MAIN + "?" + config.testServer.port | |
205 }); | |
206 }, | |
207 | |
208 ]); | |
209 }); | |
210 }); | |
211 }; | |
OLD | NEW |