diff options
author | dcheng <dcheng@chromium.org> | 2015-10-02 20:34:22 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-10-03 03:35:05 +0000 |
commit | 4dcf62a421fce8a8bd715d5dd6ff9d8f52557eae (patch) | |
tree | 771a2f48e78aadfb700d159ab8902cb9112c7e17 /extensions/renderer/resources | |
parent | 98ebd843dd1c995dde895340c53ceca2e59c9a58 (diff) | |
download | chromium_src-4dcf62a421fce8a8bd715d5dd6ff9d8f52557eae.zip chromium_src-4dcf62a421fce8a8bd715d5dd6ff9d8f52557eae.tar.gz chromium_src-4dcf62a421fce8a8bd715d5dd6ff9d8f52557eae.tar.bz2 |
Remove stash_client.js dependency on unload_event.js
unload_event is problematic because it runs JS at inopportune times, in the
main world. This allows arbitrary web content to run JS at a time when
certain invariants in Blink may not hold true.
Unfortunately, the mojo version of the serial API depends on stash_client's
current implementation. Fortunately, it's not actually used in release yet.
BUG=537660
Review URL: https://codereview.chromium.org/1381563007
Cr-Commit-Position: refs/heads/master@{#352231}
Diffstat (limited to 'extensions/renderer/resources')
-rw-r--r-- | extensions/renderer/resources/extensions_renderer_resources.grd | 1 | ||||
-rw-r--r-- | extensions/renderer/resources/stash_client.js | 7 | ||||
-rw-r--r-- | extensions/renderer/resources/unload_event.js | 33 |
3 files changed, 3 insertions, 38 deletions
diff --git a/extensions/renderer/resources/extensions_renderer_resources.grd b/extensions/renderer/resources/extensions_renderer_resources.grd index d3fcb7d..8a08705 100644 --- a/extensions/renderer/resources/extensions_renderer_resources.grd +++ b/extensions/renderer/resources/extensions_renderer_resources.grd @@ -55,7 +55,6 @@ <include name="IDR_STASH_MOJOM_JS" file="${mojom_root}\extensions\common\mojo\stash.mojom.js" use_base_dir="false" type="BINDATA" /> <include name="IDR_TEST_CUSTOM_BINDINGS_JS" file="test_custom_bindings.js" type="BINDATA" /> <include name="IDR_UNCAUGHT_EXCEPTION_HANDLER_JS" file="uncaught_exception_handler.js" type="BINDATA" /> - <include name="IDR_UNLOAD_EVENT_JS" file="unload_event.js" type="BINDATA" /> <include name="IDR_UTILS_JS" file="utils.js" type="BINDATA" /> <include name="IDR_WEB_VIEW_ACTION_REQUESTS_JS" file="guest_view/web_view/web_view_action_requests.js" type="BINDATA" /> <include name="IDR_WEB_VIEW_API_METHODS_JS" file="guest_view/web_view/web_view_api_methods.js" type="BINDATA" /> diff --git a/extensions/renderer/resources/stash_client.js b/extensions/renderer/resources/stash_client.js index 110e700c..b7f50fe 100644 --- a/extensions/renderer/resources/stash_client.js +++ b/extensions/renderer/resources/stash_client.js @@ -19,8 +19,6 @@ define('stash_client', [ var service = new stashMojom.StashService.proxyClass(new routerModule.Router( serviceProvider.connectToService(stashMojom.StashService.name))); - var unloadEvent = require('unload_event'); - /** * A callback invoked to obtain objects to stash from a particular client. * @callback module:stash_client.StashCallback @@ -149,7 +147,7 @@ define('stash_client', [ }); } - unloadEvent.addListener(function() { + function saveStashForTesting() { Promise.all($Array.map(clients, function(client) { return client.serialize(); })).then(function(stashedObjects) { @@ -160,10 +158,11 @@ define('stash_client', [ }); service.addToStash(flattenedObjectsToStash); }); - }); + } return { registerClient: registerClient, retrieve: retrieve, + saveStashForTesting, saveStashForTesting, }; }); diff --git a/extensions/renderer/resources/unload_event.js b/extensions/renderer/resources/unload_event.js deleted file mode 100644 index 753c2f0..0000000 --- a/extensions/renderer/resources/unload_event.js +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2014 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -// Special unload event. We don't use the DOM unload because that slows down -// tab shutdown. On the other hand, onUnload might not always fire, since -// Chrome will terminate renderers on shutdown (SuddenTermination). - -// Implement a primitive subset of the Event interface as needed, since if this -// was to use the real event object there would be a circular dependency. -var listeners = []; - -exports.addListener = function(listener) { - $Array.push(listeners, listener); -}; - -exports.removeListener = function(listener) { - for (var i = 0; i < listeners.length; ++i) { - if (listeners[i] == listener) { - $Array.splice(listeners, i, 1); - return; - } - } -}; - -exports.wasDispatched = false; - -// dispatch() is called from C++. -exports.dispatch = function() { - exports.wasDispatched = true; - for (var i = 0; i < listeners.length; ++i) - listeners[i](); -}; |