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

Unified Diff: chrome/test/data/extensions/browsertest/last_error/bg.js

Issue 8784009: Update more extension manifests 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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/extensions/browsertest/last_error/bg.js
===================================================================
--- chrome/test/data/extensions/browsertest/last_error/bg.js (revision 0)
+++ chrome/test/data/extensions/browsertest/last_error/bg.js (revision 0)
@@ -0,0 +1,59 @@
+// 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.
+
+function fail() {
+ window.domAutomationController.send(false);
+ throw "Failed!";
+}
+
+function succeed() {
+ window.domAutomationController.send(true);
+}
+
+function testLastError() {
+ // Make sure lastError is not yet set
+ if (chrome.tabs.lastError)
+ fail();
+
+ var maxTabId = 0;
+
+ // Find the highest tab id
+ chrome.windows.getAll({populate:true}, function(windows) {
+ // Make sure lastError is still not set. (this call have should succeeded).
+ if (chrome.tabs.lastError)
+ fail();
+
+ for (var i = 0; i < windows.length; i++) {
+ var win = windows[i];
+ for (var j = 0; j < win.tabs.length; j++) {
+ var tab = win.tabs[j];
+ if (tab.id > maxTabId)
+ maxTabId = tab.id;
+ }
+ }
+
+ // Now ask for the next highest tabId.
+ chrome.tabs.get(maxTabId + 1, function(tab) {
+ // Make sure lastError *is* set and tab is not.
+ if (!chrome.extension.lastError ||
+ !chrome.extension.lastError.message ||
+ tab)
+ fail();
+
+ window.setTimeout(finish, 10);
+ });
+ });
+}
+
+function finish() {
+ // Now make sure lastError is unset outside the callback context.
+ if (chrome.tabs.lastError)
+ fail();
+
+ succeed();
+}
+
+document.documentElement.addEventListener("click", function() {
+ testLastError();
+}, true);

Powered by Google App Engine
This is Rietveld 408576698