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

Side by Side Diff: chrome/test/data/extensions/api_test/tabs/on_updated/test.js

Issue 8762014: Move another set of extension tests to manifest_version 2 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years 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
(Empty)
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
3 // found in the LICENSE file.
4
5 var expectedEventData;
6 var capturedEventData;
7 var shouldIgnore;
8
9 function expect(data, ignoreFunc) {
10 expectedEventData = data;
11 capturedEventData = [];
12 shouldIgnore = ignoreFunc;
13 }
14
15 function checkExpectations() {
16 if (capturedEventData.length < expectedEventData.length) {
17 return;
18 }
19 chrome.test.assertEq(JSON.stringify(expectedEventData),
20 JSON.stringify(capturedEventData));
21 chrome.test.succeed();
22 }
23
24 var getURL = chrome.extension.getURL;
25
26 chrome.tabs.onUpdated.addListener(function(tabId, info, tab) {
27 console.log('---onUpdated: ' + info.status + ', ' + info.url);
28 if (shouldIgnore && shouldIgnore(info)) {
29 return;
30 }
31 capturedEventData.push(info);
32 checkExpectations();
33 });
34
35 chrome.test.runTests([
36 function browserThenRendererInitiated() {
37 // Note that a.html will set it's location.href to b.html, creating a
38 // renderer-initiated navigation.
39 expect([
40 { status: 'loading', url: getURL('browserThenRendererInitiated/a.html') },
41 { status: 'complete' },
42 { status: 'loading', url: getURL('browserThenRendererInitiated/b.html') },
43 { status: 'complete' },
44 ]);
45
46 chrome.tabs.create({ url: getURL('browserThenRendererInitiated/a.html') });
47 },
48
49 function newTab() {
50 // Test for crbug.com/27208.
51 expect([
52 { status: 'loading', url: 'chrome://newtab/' },
53 { status: 'complete' }
54 ]);
55
56 chrome.tabs.create({ url: 'chrome://newtab/' });
57 },
58
59 /*
60 // TODO(rafaelw) -- This is disabled because this test is flakey.
61 function updateDuringCreateCallback() {
62 // Test for crbug.com/27204.
63 // We have to ignore anything that comes before the about:blank loading
64 // status.
65 var ignore = true;
66 expect([
67 { status: 'loading', url: 'about:blank' },
68 { status: 'complete' }
69 ], function(info) {
70 if (info.status === 'loading' && info.url === 'about:blank') {
71 ignore = false;
72 }
73 return ignore;
74 });
75
76 chrome.tabs.create({ url: 'chrome://newtab/' }, function(tab) {
77 chrome.tabs.update(tab.id, { url: 'about:blank' });
78 });
79 }, */
80
81 function iframeNavigated() {
82 // The sequence of events goes like this:
83 // -a.html starts loading
84 // -while a.html is loading, iframe1.html (in it's onload) navigates to
85 // iframe2.html. This causes the page to continue to be in the loading state
86 // so the 'complete' status doesn't fire.
87 // -iframe2.html does a setTimeout to navigate itself to iframe3.html. This
88 // allows the page to stop loading and the 'complete' status to fire, but
89 // when the timeout fires, the pages goes back into the loading state
90 // which causes the new status: 'loading' event to fire without having
91 // changed the url.
92 expect([
93 { status: 'loading', url: getURL('iframeNavigated/a.html') },
94 { status: 'complete' },
95 { status: 'loading' },
96 { status: 'complete' },
97 ]);
98
99 chrome.tabs.create({ url: getURL('iframeNavigated/a.html') });
100 },
101
102 function internalAnchorNavigated() {
103 expect([
104 { status: 'loading', url: getURL('internalAnchorNavigated/a.html') },
105 { status: 'complete' },
106 { status: 'loading', url: getURL('internalAnchorNavigated/a.html#b') },
107 { status: 'complete' },
108 ]);
109
110 chrome.tabs.create({ url: getURL('internalAnchorNavigated/a.html') });
111 }
112 ]);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698