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

Side by Side Diff: chrome/test/data/extensions/api_test/script_badge/basics/background.js

Issue 10823142: Fix a race condition when an IconAnimation is still running at browser shutdown. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Comment tweak. Created 8 years, 4 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // Called when the user clicks on the script badge. 5 // Called when the user clicks on the script badge.
6 chrome.scriptBadge.onClicked.addListener(function(windowId) { 6 chrome.scriptBadge.onClicked.addListener(function(windowId) {
7 chrome.test.notifyPass(); 7 chrome.test.notifyPass();
8 }); 8 });
9 9
10 chrome.webNavigation.onCompleted.addListener(function(details) {
11 if (/^http:/.test(details.url)) {
not at google - send to devlin 2012/08/02 14:44:25 details.url.indexOf('http://') === 0 is a common
Jeffrey Yasskin 2012/08/02 15:11:49 Cool. Keep the idioms coming: I don't claim to kno
12 // Executing script causes an icon animation to run. Originally, if
13 // this animation was still running when the browser shut down, it
14 // would cause a crash due to the Extension being destroyed on the
15 // IO thread, and transitively causing a UI-only object to be
16 // destroyed there.
17 chrome.tabs.executeScript(
18 details.tabId,
19 {
20 // The setTimeout allows the ScriptBadgeController to
21 // reliably notice that a content script has run.
22 "code": ("window.setTimeout(function() {" +
23 " chrome.test.notifyPass();}, 1)")
24 });
25 }
26 });
27
10 chrome.test.notifyPass(); 28 chrome.test.notifyPass();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698