summaryrefslogtreecommitdiffstats
path: root/extensions/renderer/resources
diff options
context:
space:
mode:
authoryukishiino <yukishiino@chromium.org>2015-09-17 01:04:39 -0700
committerCommit bot <commit-bot@chromium.org>2015-09-17 08:05:16 +0000
commit37799a7c9a4dc1b06d627cc17bb989c25663ada3 (patch)
tree9c00f0abb0221761a57ae99276a4aafe767b8ad0 /extensions/renderer/resources
parente946b22147e475b6d452a630a82cf96d88942aa7 (diff)
downloadchromium_src-37799a7c9a4dc1b06d627cc17bb989c25663ada3.zip
chromium_src-37799a7c9a4dc1b06d627cc17bb989c25663ada3.tar.gz
chromium_src-37799a7c9a4dc1b06d627cc17bb989c25663ada3.tar.bz2
bindings: Fixes exposed JS APIs for platform apps.
We're disabling some of DOM attributes and operations for platform apps. Since event handlers and operations in Window are going to move onto the instance object, we need to update disabling code accordingly. Also fixes a way to disable addEventListener. It's defined on EventTarget.prototype, not on Window.prototype. Also it shouldn't change |this| object. This CL is a preparation of http://crrev.com/1333853002 BUG=43394, 516274 CQ_INCLUDE_TRYBOTS=tryserver.blink:linux_blink_rel Review URL: https://codereview.chromium.org/1333303002 Cr-Commit-Position: refs/heads/master@{#349376}
Diffstat (limited to 'extensions/renderer/resources')
-rw-r--r--extensions/renderer/resources/platform_app.js13
1 files changed, 7 insertions, 6 deletions
diff --git a/extensions/renderer/resources/platform_app.js b/extensions/renderer/resources/platform_app.js
index b34a303..caf935a 100644
--- a/extensions/renderer/resources/platform_app.js
+++ b/extensions/renderer/resources/platform_app.js
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-var $console = window.console;
-
/**
* Returns a function that logs a 'not available' error to the console and
* returns undefined.
@@ -14,7 +12,7 @@ function generateDisabledMethodStub(messagePrefix, opt_messageSuffix) {
var message = messagePrefix + ' is not available in packaged apps.';
if (opt_messageSuffix) message = message + ' ' + opt_messageSuffix;
return function() {
- $console.error(message);
+ console.error(message);
return;
};
}
@@ -157,10 +155,12 @@ disableGetters(window.history, 'history',
['back', 'forward', 'go', 'length', 'pushState', 'replaceState']);
// Disable find.
+disableMethods(window, 'window', ['find']);
disableMethods(Window.prototype, 'window', ['find']);
// Disable modal dialogs. Shell windows disable these anyway, but it's nice to
// warn.
+disableMethods(window, 'window', ['alert', 'confirm', 'prompt']);
disableMethods(Window.prototype, 'window', ['alert', 'confirm', 'prompt']);
// Disable window.*bar.
@@ -198,11 +198,12 @@ window.addEventListener('readystatechange', function(event) {
}, true);
// Disable onunload, onbeforeunload.
+disableSetters(window, 'window', ['onbeforeunload', 'onunload']);
disableSetters(Window.prototype, 'window', ['onbeforeunload', 'onunload']);
-var windowAddEventListener = Window.prototype.addEventListener;
-Window.prototype.addEventListener = function(type) {
+var eventTargetAddEventListener = EventTarget.prototype.addEventListener;
+EventTarget.prototype.addEventListener = function(type) {
if (type === 'unload' || type === 'beforeunload')
generateDisabledMethodStub(type)();
else
- return $Function.apply(windowAddEventListener, window, arguments);
+ return $Function.apply(eventTargetAddEventListener, this, arguments);
};