OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 function runTests() { | 5 onload = function() { |
6 var getURL = chrome.extension.getURL; | 6 var getURL = chrome.extension.getURL; |
7 chrome.tabs.create({"url": "about:blank"}, function(tab) { | 7 chrome.tabs.create({"url": "about:blank"}, function(tab) { |
8 var tabId = tab.id; | 8 var tabId = tab.id; |
9 | 9 |
10 chrome.test.runTests([ | 10 chrome.test.runTests([ |
11 // Navigates to a non-existant page. | 11 // An page that tries to load an non-existent iframe. |
12 function nonExistant() { | 12 function nonExistentIframe() { |
13 expect([ | |
14 { label: "onBeforeNavigate", | |
15 event: "onBeforeNavigate", | |
16 details: { frameId: 0, | |
17 processId: 0, | |
18 tabId: 0, | |
19 timeStamp: 0, | |
20 url: getURL('failures/nonexistant.html') }}, | |
21 { label: "onErrorOccurred", | |
22 event: "onErrorOccurred", | |
23 details: { error: "net::ERR_FILE_NOT_FOUND", | |
24 frameId: 0, | |
25 processId: 0, | |
26 tabId: 0, | |
27 timeStamp: 0, | |
28 url: getURL('failures/nonexistant.html') }}], | |
29 [["onBeforeNavigate", "onErrorOccurred"]]); | |
30 chrome.tabs.update(tabId, { url: getURL('failures/nonexistant.html') }); | |
31 }, | |
32 | |
33 // An page that tries to load an non-existant iframe. | |
34 function nonExistantIframe() { | |
35 expect([ | 13 expect([ |
36 { label: "a-onBeforeNavigate", | 14 { label: "a-onBeforeNavigate", |
37 event: "onBeforeNavigate", | 15 event: "onBeforeNavigate", |
38 details: { frameId: 0, | 16 details: { frameId: 0, |
39 processId: 0, | 17 processId: 0, |
40 tabId: 0, | 18 tabId: 0, |
41 timeStamp: 0, | 19 timeStamp: 0, |
42 url: getURL('failures/d.html') }}, | 20 url: getURL('failures/d.html') }}, |
43 { label: "a-onCommitted", | 21 { label: "a-onCommitted", |
44 event: "onCommitted", | 22 event: "onCommitted", |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 processId: 0, | 55 processId: 0, |
78 tabId: 0, | 56 tabId: 0, |
79 timeStamp: 0, | 57 timeStamp: 0, |
80 url: getURL('failures/c.html') }}], | 58 url: getURL('failures/c.html') }}], |
81 [navigationOrder("a-"), | 59 [navigationOrder("a-"), |
82 ["a-onCommitted", "b-onBeforeNavigate", "b-onErrorOccurred", | 60 ["a-onCommitted", "b-onBeforeNavigate", "b-onErrorOccurred", |
83 "a-onCompleted"]]); | 61 "a-onCompleted"]]); |
84 chrome.tabs.update(tabId, { url: getURL('failures/d.html') }); | 62 chrome.tabs.update(tabId, { url: getURL('failures/d.html') }); |
85 }, | 63 }, |
86 | 64 |
87 // An iframe navigates to a non-existant page. | 65 // An iframe navigates to a non-existent page. |
88 function nonExistantIframeNavigation() { | 66 function nonExistentIframeNavigation() { |
89 expect([ | 67 expect([ |
90 { label: "a-onBeforeNavigate", | 68 { label: "a-onBeforeNavigate", |
91 event: "onBeforeNavigate", | 69 event: "onBeforeNavigate", |
92 details: { frameId: 0, | 70 details: { frameId: 0, |
93 processId: 0, | 71 processId: 0, |
94 tabId: 0, | 72 tabId: 0, |
95 timeStamp: 0, | 73 timeStamp: 0, |
96 url: getURL('failures/a.html') }}, | 74 url: getURL('failures/a.html') }}, |
97 { label: "a-onCommitted", | 75 { label: "a-onCommitted", |
98 event: "onCommitted", | 76 event: "onCommitted", |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 details: { error: "net::ERR_ABORTED", | 179 details: { error: "net::ERR_ABORTED", |
202 frameId: 0, | 180 frameId: 0, |
203 processId: 0, | 181 processId: 0, |
204 tabId: 0, | 182 tabId: 0, |
205 timeStamp: 0, | 183 timeStamp: 0, |
206 url: getURL('failures/e.html') }}], | 184 url: getURL('failures/e.html') }}], |
207 [["onBeforeNavigate", "onCommitted", "onDOMContentLoaded", | 185 [["onBeforeNavigate", "onCommitted", "onDOMContentLoaded", |
208 "onErrorOccurred"]]); | 186 "onErrorOccurred"]]); |
209 chrome.tabs.update(tabId, { url: getURL('failures/e.html') }); | 187 chrome.tabs.update(tabId, { url: getURL('failures/e.html') }); |
210 }, | 188 }, |
| 189 |
| 190 // Navigates to a non-existent page (this test case must be last, |
| 191 // otherwise the non-existant URL breaks tests that follow, since loading |
| 192 // those test pages is seen as a non-extension -> extension URL |
| 193 // transition, which is forbidden by web_accessible_resources enforcement |
| 194 // in manifest version 2.) |
| 195 function nonExistent() { |
| 196 expect([ |
| 197 { label: "onBeforeNavigate", |
| 198 event: "onBeforeNavigate", |
| 199 details: { frameId: 0, |
| 200 processId: 0, |
| 201 tabId: 0, |
| 202 timeStamp: 0, |
| 203 url: getURL('failures/nonexistent.html') }}, |
| 204 { label: "onErrorOccurred", |
| 205 event: "onErrorOccurred", |
| 206 details: { error: "net::ERR_FILE_NOT_FOUND", |
| 207 frameId: 0, |
| 208 processId: 0, |
| 209 tabId: 0, |
| 210 timeStamp: 0, |
| 211 url: getURL('failures/nonexistent.html') }}], |
| 212 [["onBeforeNavigate", "onErrorOccurred"]]); |
| 213 chrome.tabs.update(tabId, { url: getURL('failures/nonexistent.html') }); |
| 214 }, |
211 ]); | 215 ]); |
212 }); | 216 }); |
213 } | 217 }; |
OLD | NEW |