Do not announce robot account token before account ID is available
[chromium-blink-merge.git] / chrome / test / data / extensions / api_test / webnavigation / failures / test_failures.js
blobc32ec513bfdb60536c9f1fff13b847c629a77222
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.
5 onload = function() {
6   var getURL = chrome.extension.getURL;
7   chrome.tabs.create({"url": "about:blank"}, function(tab) {
8     var tabId = tab.id;
10     chrome.test.runTests([
11       // An page that tries to load an non-existent iframe.
12       function nonExistentIframe() {
13         expect([
14           { label: "a-onBeforeNavigate",
15             event: "onBeforeNavigate",
16             details: { frameId: 0,
17                        parentFrameId: -1,
18                        processId: 0,
19                        tabId: 0,
20                        timeStamp: 0,
21                        url: getURL('d.html') }},
22           { label: "a-onCommitted",
23             event: "onCommitted",
24             details: { frameId: 0,
25                        processId: 0,
26                        tabId: 0,
27                        timeStamp: 0,
28                        transitionQualifiers: [],
29                        transitionType: "link",
30                        url: getURL('d.html') }},
31           { label: "a-onDOMContentLoaded",
32             event: "onDOMContentLoaded",
33             details: { frameId: 0,
34                        processId: 0,
35                        tabId: 0,
36                        timeStamp: 0,
37                        url: getURL('d.html') }},
38           { label: "a-onCompleted",
39             event: "onCompleted",
40             details: { frameId: 0,
41                        processId: 0,
42                        tabId: 0,
43                        timeStamp: 0,
44                        url: getURL('d.html') }},
45           { label: "b-onBeforeNavigate",
46             event: "onBeforeNavigate",
47             details: { frameId: 1,
48                        parentFrameId: 0,
49                        processId: 0,
50                        tabId: 0,
51                        timeStamp: 0,
52                        url: getURL('c.html') }},
53           { label: "b-onErrorOccurred",
54             event: "onErrorOccurred",
55             details: { error: "net::ERR_FILE_NOT_FOUND",
56                        frameId: 1,
57                        processId: 0,
58                        tabId: 0,
59                        timeStamp: 0,
60                        url: getURL('c.html') }}],
61           [navigationOrder("a-"),
62             ["a-onCommitted", "b-onBeforeNavigate", "b-onErrorOccurred",
63              "a-onCompleted"]]);
64         chrome.tabs.update(tabId, { url: getURL('d.html') });
65       },
67       // An iframe navigates to a non-existent page.
68       function nonExistentIframeNavigation() {
69         expect([
70           { label: "a-onBeforeNavigate",
71             event: "onBeforeNavigate",
72             details: { frameId: 0,
73                        parentFrameId: -1,
74                        processId: 0,
75                        tabId: 0,
76                        timeStamp: 0,
77                        url: getURL('a.html') }},
78           { label: "a-onCommitted",
79             event: "onCommitted",
80             details: { frameId: 0,
81                        processId: 0,
82                        tabId: 0,
83                        timeStamp: 0,
84                        transitionQualifiers: [],
85                        transitionType: "link",
86                        url: getURL('a.html') }},
87           { label: "a-onDOMContentLoaded",
88             event: "onDOMContentLoaded",
89             details: { frameId: 0,
90                        processId: 0,
91                        tabId: 0,
92                        timeStamp: 0,
93                        url: getURL('a.html') }},
94           { label: "a-onCompleted",
95             event: "onCompleted",
96             details: { frameId: 0,
97                        processId: 0,
98                        tabId: 0,
99                        timeStamp: 0,
100                        url: getURL('a.html') }},
101           { label: "b-onBeforeNavigate",
102             event: "onBeforeNavigate",
103             details: { frameId: 1,
104                        parentFrameId: 0,
105                        processId: 0,
106                        tabId: 0,
107                        timeStamp: 0,
108                        url: getURL('b.html') }},
109           { label: "b-onCommitted",
110             event: "onCommitted",
111             details: { frameId: 1,
112                        processId: 0,
113                        tabId: 0,
114                        timeStamp: 0,
115                        transitionQualifiers: [],
116                        transitionType: "auto_subframe",
117                        url: getURL('b.html') }},
118           { label: "b-onDOMContentLoaded",
119             event: "onDOMContentLoaded",
120             details: { frameId: 1,
121                        processId: 0,
122                        tabId: 0,
123                        timeStamp: 0,
124                        url: getURL('b.html') }},
125           { label: "b-onCompleted",
126             event: "onCompleted",
127             details: { frameId: 1,
128                        processId: 0,
129                        tabId: 0,
130                        timeStamp: 0,
131                        url: getURL('b.html') }},
132           { label: "c-onBeforeNavigate",
133             event: "onBeforeNavigate",
134             details: { frameId: 1,
135                        parentFrameId: 0,
136                        processId: 0,
137                        tabId: 0,
138                        timeStamp: 0,
139                        url: getURL('c.html') }},
140           { label: "c-onErrorOccurred",
141             event: "onErrorOccurred",
142             details: { error: "net::ERR_FILE_NOT_FOUND",
143                        frameId: 1,
144                        processId: 0,
145                        tabId: 0,
146                        timeStamp: 0,
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') });
154       },
156       // Cancel a navigation after it is already committed.
157       function cancel() {
158         expect([
159           { label: "onBeforeNavigate",
160             event: "onBeforeNavigate",
161             details: { frameId: 0,
162                        parentFrameId: -1,
163                        processId: 0,
164                        tabId: 0,
165                        timeStamp: 0,
166                        url: getURL('e.html') }},
167           { label: "onCommitted",
168             event: "onCommitted",
169             details: { frameId: 0,
170                        processId: 0,
171                        tabId: 0,
172                        timeStamp: 0,
173                        transitionQualifiers: [],
174                        transitionType: "link",
175                        url: getURL('e.html') }},
176           { label: "onDOMContentLoaded",
177             event: "onDOMContentLoaded",
178             details: { frameId: 0,
179                        processId: 0,
180                        tabId: 0,
181                        timeStamp: 0,
182                        url: getURL('e.html') }},
183           { label: "onErrorOccurred",
184             event: "onErrorOccurred",
185             details: { error: "net::ERR_ABORTED",
186                        frameId: 0,
187                        processId: 0,
188                        tabId: 0,
189                        timeStamp: 0,
190                        url: getURL('e.html') }}],
191           [["onBeforeNavigate", "onCommitted", "onDOMContentLoaded",
192             "onErrorOccurred"]]);
193         chrome.tabs.update(tabId, { url: getURL('e.html') });
194       },
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() {
202         expect([
203           { label: "onBeforeNavigate",
204             event: "onBeforeNavigate",
205             details: { frameId: 0,
206                        parentFrameId: -1,
207                        processId: 0,
208                        tabId: 0,
209                        timeStamp: 0,
210                        url: getURL('nonexistent.html') }},
211           { label: "onErrorOccurred",
212             event: "onErrorOccurred",
213             details: { error: "net::ERR_FILE_NOT_FOUND",
214                        frameId: 0,
215                        processId: 0,
216                        tabId: 0,
217                        timeStamp: 0,
218                        url: getURL('nonexistent.html') }}],
219           [["onBeforeNavigate", "onErrorOccurred"]]);
220         chrome.tabs.update(tabId, { url: getURL('nonexistent.html') });
221       },
222     ]);
223   });