1 // Copyright 2013 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.
6 var getURL
= chrome
.extension
.getURL
;
7 chrome
.tabs
.create({"url": "about:blank"}, function(tab
) {
10 chrome
.test
.runTests([
11 // An page that tries to load an non-existent iframe.
12 function nonExistentIframe() {
14 { label
: "a-onBeforeNavigate",
15 event
: "onBeforeNavigate",
16 details
: { frameId
: 0,
21 url
: getURL('d.html') }},
22 { label
: "a-onCommitted",
24 details
: { frameId
: 0,
28 transitionQualifiers
: [],
29 transitionType
: "link",
30 url
: getURL('d.html') }},
31 { label
: "a-onDOMContentLoaded",
32 event
: "onDOMContentLoaded",
33 details
: { frameId
: 0,
37 url
: getURL('d.html') }},
38 { label
: "a-onCompleted",
40 details
: { frameId
: 0,
44 url
: getURL('d.html') }},
45 { label
: "b-onBeforeNavigate",
46 event
: "onBeforeNavigate",
47 details
: { frameId
: 1,
52 url
: getURL('c.html') }},
53 { label
: "b-onErrorOccurred",
54 event
: "onErrorOccurred",
55 details
: { error
: "net::ERR_FILE_NOT_FOUND",
60 url
: getURL('c.html') }}],
61 [navigationOrder("a-"),
62 ["a-onCommitted", "b-onBeforeNavigate", "b-onErrorOccurred",
64 chrome
.tabs
.update(tabId
, { url
: getURL('d.html') });
67 // An iframe navigates to a non-existent page.
68 function nonExistentIframeNavigation() {
70 { label
: "a-onBeforeNavigate",
71 event
: "onBeforeNavigate",
72 details
: { frameId
: 0,
77 url
: getURL('a.html') }},
78 { label
: "a-onCommitted",
80 details
: { frameId
: 0,
84 transitionQualifiers
: [],
85 transitionType
: "link",
86 url
: getURL('a.html') }},
87 { label
: "a-onDOMContentLoaded",
88 event
: "onDOMContentLoaded",
89 details
: { frameId
: 0,
93 url
: getURL('a.html') }},
94 { label
: "a-onCompleted",
96 details
: { frameId
: 0,
100 url
: getURL('a.html') }},
101 { label
: "b-onBeforeNavigate",
102 event
: "onBeforeNavigate",
103 details
: { frameId
: 1,
108 url
: getURL('b.html') }},
109 { label
: "b-onCommitted",
110 event
: "onCommitted",
111 details
: { frameId
: 1,
115 transitionQualifiers
: [],
116 transitionType
: "auto_subframe",
117 url
: getURL('b.html') }},
118 { label
: "b-onDOMContentLoaded",
119 event
: "onDOMContentLoaded",
120 details
: { frameId
: 1,
124 url
: getURL('b.html') }},
125 { label
: "b-onCompleted",
126 event
: "onCompleted",
127 details
: { frameId
: 1,
131 url
: getURL('b.html') }},
132 { label
: "c-onBeforeNavigate",
133 event
: "onBeforeNavigate",
134 details
: { frameId
: 1,
139 url
: getURL('c.html') }},
140 { label
: "c-onErrorOccurred",
141 event
: "onErrorOccurred",
142 details
: { error
: "net::ERR_FILE_NOT_FOUND",
147 url
: getURL('c.html') }}],
148 [ navigationOrder("a-"),
149 navigationOrder("b-"),
150 isIFrameOf("b-", "a-"),
151 isLoadedBy("c-", "b-"),
152 ["c-onBeforeNavigate", "c-onErrorOccurred"]]);
153 chrome
.tabs
.update(tabId
, { url
: getURL('a.html') });
156 // Cancel a navigation after it is already committed.
159 { label
: "onBeforeNavigate",
160 event
: "onBeforeNavigate",
161 details
: { frameId
: 0,
166 url
: getURL('e.html') }},
167 { label
: "onCommitted",
168 event
: "onCommitted",
169 details
: { frameId
: 0,
173 transitionQualifiers
: [],
174 transitionType
: "link",
175 url
: getURL('e.html') }},
176 { label
: "onDOMContentLoaded",
177 event
: "onDOMContentLoaded",
178 details
: { frameId
: 0,
182 url
: getURL('e.html') }},
183 { label
: "onErrorOccurred",
184 event
: "onErrorOccurred",
185 details
: { error
: "net::ERR_ABORTED",
190 url
: getURL('e.html') }}],
191 [["onBeforeNavigate", "onCommitted", "onDOMContentLoaded",
192 "onErrorOccurred"]]);
193 chrome
.tabs
.update(tabId
, { url
: getURL('e.html') });
196 // Navigates to a non-existent page (this test case must be last,
197 // otherwise the non-existant URL breaks tests that follow, since loading
198 // those test pages is seen as a non-extension -> extension URL
199 // transition, which is forbidden by web_accessible_resources enforcement
200 // in manifest version 2.)
201 function nonExistent() {
203 { label
: "onBeforeNavigate",
204 event
: "onBeforeNavigate",
205 details
: { frameId
: 0,
210 url
: getURL('nonexistent.html') }},
211 { label
: "onErrorOccurred",
212 event
: "onErrorOccurred",
213 details
: { error
: "net::ERR_FILE_NOT_FOUND",
218 url
: getURL('nonexistent.html') }}],
219 [["onBeforeNavigate", "onErrorOccurred"]]);
220 chrome
.tabs
.update(tabId
, { url
: getURL('nonexistent.html') });