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

Side by Side 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 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 function fail() {
6 window.domAutomationController.send(false);
7 throw "Failed!";
8 }
9
10 function succeed() {
11 window.domAutomationController.send(true);
12 }
13
14 function testLastError() {
15 // Make sure lastError is not yet set
16 if (chrome.tabs.lastError)
17 fail();
18
19 var maxTabId = 0;
20
21 // Find the highest tab id
22 chrome.windows.getAll({populate:true}, function(windows) {
23 // Make sure lastError is still not set. (this call have should succeeded).
24 if (chrome.tabs.lastError)
25 fail();
26
27 for (var i = 0; i < windows.length; i++) {
28 var win = windows[i];
29 for (var j = 0; j < win.tabs.length; j++) {
30 var tab = win.tabs[j];
31 if (tab.id > maxTabId)
32 maxTabId = tab.id;
33 }
34 }
35
36 // Now ask for the next highest tabId.
37 chrome.tabs.get(maxTabId + 1, function(tab) {
38 // Make sure lastError *is* set and tab is not.
39 if (!chrome.extension.lastError ||
40 !chrome.extension.lastError.message ||
41 tab)
42 fail();
43
44 window.setTimeout(finish, 10);
45 });
46 });
47 }
48
49 function finish() {
50 // Now make sure lastError is unset outside the callback context.
51 if (chrome.tabs.lastError)
52 fail();
53
54 succeed();
55 }
56
57 document.documentElement.addEventListener("click", function() {
58 testLastError();
59 }, true);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698