Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(332)

Side by Side Diff: chrome/test/data/extensions/api_test/webnavigation/test_openTab.js

Issue 7859014: Refactor ExtensionApiTest.WebNavigationEvents* to not rely on window.setTimeout (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 function runTests() {
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 // Opens a new tab from javascript. 11 // Opens a new tab from javascript.
12 function openTab() { 12 function openTab() {
13 expect([ 13 expect([
14 [ "onBeforeNavigate", 14 { label: "a-onBeforeNavigate",
15 { frameId: 0, 15 event: "onBeforeNavigate",
16 tabId: 0, 16 details: { frameId: 0,
17 timeStamp: 0, 17 tabId: 0,
18 url: getURL('openTab/a.html') }], 18 timeStamp: 0,
19 [ "onCommitted", 19 url: getURL('openTab/a.html') }},
20 { frameId: 0, 20 { label: "a-onCommitted",
21 tabId: 0, 21 event: "onCommitted",
22 timeStamp: 0, 22 details: { frameId: 0,
23 transitionQualifiers: [], 23 tabId: 0,
24 transitionType: "link", 24 timeStamp: 0,
25 url: getURL('openTab/a.html') }], 25 transitionQualifiers: [],
26 [ "onDOMContentLoaded", 26 transitionType: "link",
27 { frameId: 0, 27 url: getURL('openTab/a.html') }},
28 tabId: 0, 28 { label: "a-onDOMContentLoaded",
29 timeStamp: 0, 29 event: "onDOMContentLoaded",
30 url: getURL('openTab/a.html') }], 30 details: { frameId: 0,
31 [ "onCompleted", 31 tabId: 0,
32 { frameId: 0, 32 timeStamp: 0,
33 tabId: 0, 33 url: getURL('openTab/a.html') }},
34 timeStamp: 0, 34 { label: "a-onCompleted",
35 url: getURL('openTab/a.html') }], 35 event: "onCompleted",
36 [ "onCreatedNavigationTarget", 36 details: { frameId: 0,
37 { sourceFrameId: 0, 37 tabId: 0,
38 sourceTabId: 0, 38 timeStamp: 0,
39 tabId: 1, 39 url: getURL('openTab/a.html') }},
40 timeStamp: 0, 40 { label: "a-onCreatedNavigationTarget",
41 url: getURL('openTab/b.html') }], 41 event: "onCreatedNavigationTarget",
42 [ "onBeforeNavigate", 42 details: { sourceFrameId: 0,
43 { frameId: 0, 43 sourceTabId: 0,
44 tabId: 1, 44 tabId: 1,
45 timeStamp: 0, 45 timeStamp: 0,
46 url: getURL('openTab/b.html') }], 46 url: getURL('openTab/b.html') }},
47 [ "onCommitted", 47 { label: "b-onBeforeNavigate",
48 { frameId: 0, 48 event: "onBeforeNavigate",
49 tabId: 1, 49 details: { frameId: 0,
50 timeStamp: 0, 50 tabId: 1,
51 transitionQualifiers: [], 51 timeStamp: 0,
52 transitionType: "link", 52 url: getURL('openTab/b.html') }},
53 url: getURL('openTab/b.html') }], 53 { label: "b-onCommitted",
54 [ "onDOMContentLoaded", 54 event: "onCommitted",
55 { frameId: 0, 55 details: { frameId: 0,
56 tabId: 1, 56 tabId: 1,
57 timeStamp: 0, 57 timeStamp: 0,
58 url: getURL('openTab/b.html') }], 58 transitionQualifiers: [],
59 [ "onCompleted", 59 transitionType: "link",
60 { frameId: 0, 60 url: getURL('openTab/b.html') }},
61 tabId: 1, 61 { label: "b-onDOMContentLoaded",
62 timeStamp: 0, 62 event: "onDOMContentLoaded",
63 url: getURL('openTab/b.html') }]]); 63 details: { frameId: 0,
64 tabId: 1,
65 timeStamp: 0,
66 url: getURL('openTab/b.html') }},
67 { label: "b-onCompleted",
68 event: "onCompleted",
69 details: { frameId: 0,
70 tabId: 1,
71 timeStamp: 0,
72 url: getURL('openTab/b.html') }}],
73 [ navigationOrder("a-"),
74 navigationOrder("b-"),
75 ["a-onDOMContentLoaded", "a-onCreatedNavigationTarget",
76 "b-onBeforeNavigate"]]);
64 chrome.tabs.update(tabId, { url: getURL('openTab/a.html') }); 77 chrome.tabs.update(tabId, { url: getURL('openTab/a.html') });
65 }, 78 },
66 79
67 // Opens a new tab from javascript within an iframe. 80 // Opens a new tab from javascript within an iframe.
68 function openTabFrame() { 81 function openTabFrame() {
69 expect([ 82 expect([
70 [ "onBeforeNavigate", 83 { label: "c-onBeforeNavigate",
71 { frameId: 0, 84 event: "onBeforeNavigate",
72 tabId: 0, 85 details: { frameId: 0,
73 timeStamp: 0, 86 tabId: 0,
74 url: getURL('openTab/c.html') }], 87 timeStamp: 0,
75 [ "onCommitted", 88 url: getURL('openTab/c.html') }},
76 { frameId: 0, 89 { label: "c-onCommitted",
77 tabId: 0, 90 event: "onCommitted",
78 timeStamp: 0, 91 details: { frameId: 0,
79 transitionQualifiers: [], 92 tabId: 0,
80 transitionType: "link", 93 timeStamp: 0,
81 url: getURL('openTab/c.html') }], 94 transitionQualifiers: [],
82 [ "onBeforeNavigate", 95 transitionType: "link",
83 { frameId: 1, 96 url: getURL('openTab/c.html') }},
84 tabId: 0, 97 { label: "c-onDOMContentLoaded",
85 timeStamp: 0, 98 event: "onDOMContentLoaded",
86 url: getURL('openTab/a.html') }], 99 details: { frameId: 0,
87 [ "onDOMContentLoaded", 100 tabId: 0,
88 { frameId: 0, 101 timeStamp: 0,
89 tabId: 0, 102 url: getURL('openTab/c.html') }},
90 timeStamp: 0, 103 { label: "c-onCompleted",
91 url: getURL('openTab/c.html') }], 104 event: "onCompleted",
92 [ "onCommitted", 105 details: { frameId: 0,
93 { frameId: 1, 106 tabId: 0,
94 tabId: 0, 107 timeStamp: 0,
95 timeStamp: 0, 108 url: getURL('openTab/c.html') }},
96 transitionQualifiers: [], 109 { label: "a-onBeforeNavigate",
97 transitionType: "auto_subframe", 110 event: "onBeforeNavigate",
98 url: getURL('openTab/a.html') }], 111 details: { frameId: 1,
99 [ "onDOMContentLoaded", 112 tabId: 0,
100 { frameId: 1, 113 timeStamp: 0,
101 tabId: 0, 114 url: getURL('openTab/a.html') }},
102 timeStamp: 0, 115 { label: "a-onCommitted",
103 url: getURL('openTab/a.html') }], 116 event: "onCommitted",
104 [ "onCompleted", 117 details: { frameId: 1,
105 { frameId: 1, 118 tabId: 0,
106 tabId: 0, 119 timeStamp: 0,
107 timeStamp: 0, 120 transitionQualifiers: [],
108 url: getURL('openTab/a.html') }], 121 transitionType: "auto_subframe",
109 [ "onCompleted", 122 url: getURL('openTab/a.html') }},
110 { frameId: 0, 123 { label: "a-onDOMContentLoaded",
111 tabId: 0, 124 event: "onDOMContentLoaded",
112 timeStamp: 0, 125 details: { frameId: 1,
113 url: getURL('openTab/c.html') }], 126 tabId: 0,
114 [ "onCreatedNavigationTarget", 127 timeStamp: 0,
115 { sourceFrameId: 1, 128 url: getURL('openTab/a.html') }},
116 sourceTabId: 0, 129 { label: "a-onCompleted",
117 tabId: 1, 130 event: "onCompleted",
118 timeStamp: 0, 131 details: { frameId: 1,
119 url: getURL('openTab/b.html') }], 132 tabId: 0,
120 [ "onBeforeNavigate", 133 timeStamp: 0,
121 { frameId: 0, 134 url: getURL('openTab/a.html') }},
122 tabId: 1, 135 { label: "a-onCreatedNavigationTarget",
123 timeStamp: 0, 136 event: "onCreatedNavigationTarget",
124 url: getURL('openTab/b.html') }], 137 details: { sourceFrameId: 1,
125 [ "onCommitted", 138 sourceTabId: 0,
126 { frameId: 0, 139 tabId: 1,
127 tabId: 1, 140 timeStamp: 0,
128 timeStamp: 0, 141 url: getURL('openTab/b.html') }},
129 transitionQualifiers: [], 142 { label: "b-onBeforeNavigate",
130 transitionType: "link", 143 event: "onBeforeNavigate",
131 url: getURL('openTab/b.html') }], 144 details: { frameId: 0,
132 [ "onDOMContentLoaded", 145 tabId: 1,
133 { frameId: 0, 146 timeStamp: 0,
134 tabId: 1, 147 url: getURL('openTab/b.html') }},
135 timeStamp: 0, 148 { label: "b-onCommitted",
136 url: getURL('openTab/b.html') }], 149 event: "onCommitted",
137 [ "onCompleted", 150 details: { frameId: 0,
138 { frameId: 0, 151 tabId: 1,
139 tabId: 1, 152 timeStamp: 0,
140 timeStamp: 0, 153 transitionQualifiers: [],
141 url: getURL('openTab/b.html') }]]); 154 transitionType: "link",
155 url: getURL('openTab/b.html') }},
156 { label: "b-onDOMContentLoaded",
157 event: "onDOMContentLoaded",
158 details: { frameId: 0,
159 tabId: 1,
160 timeStamp: 0,
161 url: getURL('openTab/b.html') }},
162 { label: "b-onCompleted",
163 event: "onCompleted",
164 details: { frameId: 0,
165 tabId: 1,
166 timeStamp: 0,
167 url: getURL('openTab/b.html') }}],
168 [ navigationOrder("a-"),
169 navigationOrder("b-"),
170 navigationOrder("c-"),
171 isIFrameOf("a-", "c-"),
172 ["a-onDOMContentLoaded", "a-onCreatedNavigationTarget",
173 "b-onBeforeNavigate"]]);
142 chrome.tabs.update(tabId, { url: getURL('openTab/c.html') }); 174 chrome.tabs.update(tabId, { url: getURL('openTab/c.html') });
143 }, 175 },
144 ]); 176 ]);
145 }); 177 });
146 } 178 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698