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

Side by Side Diff: chrome/renderer/resources/extensions/unload_event.js

Issue 17451011: Make the externally connectable browser test clobber all of the builtins, (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: hopefully fix tests Created 7 years, 6 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 // Special unload event. We don't use the DOM unload because that slows down 5 // Special unload event. We don't use the DOM unload because that slows down
6 // tab shutdown. On the other hand, onUnload might not always fire, since 6 // tab shutdown. On the other hand, onUnload might not always fire, since
7 // Chrome will terminate renderers on shutdown (SuddenTermination). 7 // Chrome will terminate renderers on shutdown (SuddenTermination).
8 8
9 // Implement a primitive subset of the Event interface as needed, since if this 9 // Implement a primitive subset of the Event interface as needed, since if this
10 // was to use the real event object there would be a circular dependency. 10 // was to use the real event object there would be a circular dependency.
11 var listeners = []; 11 var listeners = [];
12 12
13 exports.addListener = function(listener) { 13 exports.addListener = function(listener) {
14 listeners.push(listener); 14 $Array.push(listeners, listener);
15 }; 15 };
16 16
17 exports.removeListener = function(listener) { 17 exports.removeListener = function(listener) {
18 for (var i = 0; i < listeners.length; ++i) { 18 for (var i = 0; i < listeners.length; ++i) {
19 if (listeners[i] == listener) { 19 if (listeners[i] == listener) {
20 listeners.splice(i, 1); 20 $Array.splice(listeners, i, 1);
21 return; 21 return;
22 } 22 }
23 } 23 }
24 }; 24 };
25 25
26 exports.wasDispatched = false; 26 exports.wasDispatched = false;
27 27
28 // dispatch() is called from C++. 28 // dispatch() is called from C++.
29 exports.dispatch = function() { 29 exports.dispatch = function() {
30 exports.wasDispatched = true; 30 exports.wasDispatched = true;
31 for (var i = 0; i < listeners.length; ++i) 31 for (var i = 0; i < listeners.length; ++i)
32 listeners[i](); 32 listeners[i]();
33 }; 33 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698