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

Side by Side Diff: extensions/renderer/resources/platform_app.js

Issue 482603002: Unify logic of stack trace generation for extension errors (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add $Error and $String.indexOf to safe builtins Created 6 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 var $console = window.console; 5 var $console = window.console;
6 6
7 /** 7 /**
8 * Returns a function that logs a 'not available' error to the console and 8 * Returns a function that logs a 'not available' error to the console and
9 * returns undefined. 9 * returns undefined.
10 * 10 *
(...skipping 10 matching lines...) Expand all
21 21
22 /** 22 /**
23 * Returns a function that throws a 'not available' error. 23 * Returns a function that throws a 'not available' error.
24 * 24 *
25 * @param {string} messagePrefix text to prepend to the exception message. 25 * @param {string} messagePrefix text to prepend to the exception message.
26 */ 26 */
27 function generateThrowingMethodStub(messagePrefix, opt_messageSuffix) { 27 function generateThrowingMethodStub(messagePrefix, opt_messageSuffix) {
28 var message = messagePrefix + ' is not available in packaged apps.'; 28 var message = messagePrefix + ' is not available in packaged apps.';
29 if (opt_messageSuffix) message = message + ' ' + opt_messageSuffix; 29 if (opt_messageSuffix) message = message + ' ' + opt_messageSuffix;
30 return function() { 30 return function() {
31 throw new Error(message); 31 throw new $Error.self(message);
not at google - send to devlin 2014/08/19 16:45:56 new Error()
32 }; 32 };
33 } 33 }
34 34
35 /** 35 /**
36 * Replaces the given methods of the passed in object with stubs that log 36 * Replaces the given methods of the passed in object with stubs that log
37 * 'not available' errors to the console and return undefined. 37 * 'not available' errors to the console and return undefined.
38 * 38 *
39 * This should be used on methods attached via non-configurable properties, 39 * This should be used on methods attached via non-configurable properties,
40 * such as window.alert. disableGetters should be used when possible, because 40 * such as window.alert. disableGetters should be used when possible, because
41 * it is friendlier towards feature detection. 41 * it is friendlier towards feature detection.
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 198
199 // Disable onunload, onbeforeunload. 199 // Disable onunload, onbeforeunload.
200 disableSetters(Window.prototype, 'window', ['onbeforeunload', 'onunload']); 200 disableSetters(Window.prototype, 'window', ['onbeforeunload', 'onunload']);
201 var windowAddEventListener = Window.prototype.addEventListener; 201 var windowAddEventListener = Window.prototype.addEventListener;
202 Window.prototype.addEventListener = function(type) { 202 Window.prototype.addEventListener = function(type) {
203 if (type === 'unload' || type === 'beforeunload') 203 if (type === 'unload' || type === 'beforeunload')
204 generateDisabledMethodStub(type)(); 204 generateDisabledMethodStub(type)();
205 else 205 else
206 return $Function.apply(windowAddEventListener, window, arguments); 206 return $Function.apply(windowAddEventListener, window, arguments);
207 }; 207 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698