OLD | NEW |
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 /** | 5 /** |
6 * Returns a function that throws a 'not available' exception when called. | 6 * Returns a function that throws a 'not available' exception when called. |
7 * | 7 * |
8 * @param {string} messagePrefix text to prepend to the exception message. | 8 * @param {string} messagePrefix text to prepend to the exception message. |
9 */ | 9 */ |
10 function generateDisabledMethodStub(messagePrefix, opt_messageSuffix) { | 10 function generateDisabledMethodStub(messagePrefix, opt_messageSuffix) { |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 // Disable onunload, onbeforeunload. | 127 // Disable onunload, onbeforeunload. |
128 Window.prototype.__defineSetter__( | 128 Window.prototype.__defineSetter__( |
129 'onbeforeunload', generateDisabledMethodStub('onbeforeunload')); | 129 'onbeforeunload', generateDisabledMethodStub('onbeforeunload')); |
130 Window.prototype.__defineSetter__( | 130 Window.prototype.__defineSetter__( |
131 'onunload', generateDisabledMethodStub('onunload')); | 131 'onunload', generateDisabledMethodStub('onunload')); |
132 var windowAddEventListener = Window.prototype.addEventListener; | 132 var windowAddEventListener = Window.prototype.addEventListener; |
133 Window.prototype.addEventListener = function(type) { | 133 Window.prototype.addEventListener = function(type) { |
134 if (type === 'unload' || type === 'beforeunload') | 134 if (type === 'unload' || type === 'beforeunload') |
135 generateDisabledMethodStub(type)(); | 135 generateDisabledMethodStub(type)(); |
136 else | 136 else |
137 return windowAddEventListener.apply(window, arguments); | 137 return $Function.apply(windowAddEventListener, window, arguments); |
138 }; | 138 }; |
OLD | NEW |