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

Unified 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, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/extensions/api_test/tabs/on_updated/test.js
===================================================================
--- chrome/test/data/extensions/api_test/tabs/on_updated/test.js (revision 0)
+++ chrome/test/data/extensions/api_test/tabs/on_updated/test.js (revision 0)
@@ -0,0 +1,112 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+var expectedEventData;
+var capturedEventData;
+var shouldIgnore;
+
+function expect(data, ignoreFunc) {
+ expectedEventData = data;
+ capturedEventData = [];
+ shouldIgnore = ignoreFunc;
+}
+
+function checkExpectations() {
+ if (capturedEventData.length < expectedEventData.length) {
+ return;
+ }
+ chrome.test.assertEq(JSON.stringify(expectedEventData),
+ JSON.stringify(capturedEventData));
+ chrome.test.succeed();
+}
+
+var getURL = chrome.extension.getURL;
+
+chrome.tabs.onUpdated.addListener(function(tabId, info, tab) {
+ console.log('---onUpdated: ' + info.status + ', ' + info.url);
+ if (shouldIgnore && shouldIgnore(info)) {
+ return;
+ }
+ capturedEventData.push(info);
+ checkExpectations();
+});
+
+chrome.test.runTests([
+ function browserThenRendererInitiated() {
+ // Note that a.html will set it's location.href to b.html, creating a
+ // renderer-initiated navigation.
+ expect([
+ { status: 'loading', url: getURL('browserThenRendererInitiated/a.html') },
+ { status: 'complete' },
+ { status: 'loading', url: getURL('browserThenRendererInitiated/b.html') },
+ { status: 'complete' },
+ ]);
+
+ chrome.tabs.create({ url: getURL('browserThenRendererInitiated/a.html') });
+ },
+
+ function newTab() {
+ // Test for crbug.com/27208.
+ expect([
+ { status: 'loading', url: 'chrome://newtab/' },
+ { status: 'complete' }
+ ]);
+
+ chrome.tabs.create({ url: 'chrome://newtab/' });
+ },
+
+ /*
+ // TODO(rafaelw) -- This is disabled because this test is flakey.
+ function updateDuringCreateCallback() {
+ // Test for crbug.com/27204.
+ // We have to ignore anything that comes before the about:blank loading
+ // status.
+ var ignore = true;
+ expect([
+ { status: 'loading', url: 'about:blank' },
+ { status: 'complete' }
+ ], function(info) {
+ if (info.status === 'loading' && info.url === 'about:blank') {
+ ignore = false;
+ }
+ return ignore;
+ });
+
+ chrome.tabs.create({ url: 'chrome://newtab/' }, function(tab) {
+ chrome.tabs.update(tab.id, { url: 'about:blank' });
+ });
+ }, */
+
+ function iframeNavigated() {
+ // The sequence of events goes like this:
+ // -a.html starts loading
+ // -while a.html is loading, iframe1.html (in it's onload) navigates to
+ // iframe2.html. This causes the page to continue to be in the loading state
+ // so the 'complete' status doesn't fire.
+ // -iframe2.html does a setTimeout to navigate itself to iframe3.html. This
+ // allows the page to stop loading and the 'complete' status to fire, but
+ // when the timeout fires, the pages goes back into the loading state
+ // which causes the new status: 'loading' event to fire without having
+ // changed the url.
+ expect([
+ { status: 'loading', url: getURL('iframeNavigated/a.html') },
+ { status: 'complete' },
+ { status: 'loading' },
+ { status: 'complete' },
+ ]);
+
+ chrome.tabs.create({ url: getURL('iframeNavigated/a.html') });
+ },
+
+ function internalAnchorNavigated() {
+ expect([
+ { status: 'loading', url: getURL('internalAnchorNavigated/a.html') },
+ { status: 'complete' },
+ { status: 'loading', url: getURL('internalAnchorNavigated/a.html#b') },
+ { status: 'complete' },
+ ]);
+
+ chrome.tabs.create({ url: getURL('internalAnchorNavigated/a.html') });
+ }
+]);

Powered by Google App Engine
This is Rietveld 408576698