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

Unified Diff: chrome/test/data/extensions/platform_apps/web_view/shim/inject_comm_channel.js

Issue 140073002: <webview>: navigating to WebStore should fire a loadabort instead of crashing. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge with ToT Created 6 years, 11 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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/extensions/platform_apps/web_view/shim/inject_comm_channel.js
diff --git a/chrome/test/data/extensions/platform_apps/web_view/shim/inject_comm_channel.js b/chrome/test/data/extensions/platform_apps/web_view/shim/inject_comm_channel.js
index c5cc2d5ee03f915c8069d180eeab4982cd24ac0f..0566638de306dcb2717d5c57f14e0c3e982e2ed1 100644
--- a/chrome/test/data/extensions/platform_apps/web_view/shim/inject_comm_channel.js
+++ b/chrome/test/data/extensions/platform_apps/web_view/shim/inject_comm_channel.js
@@ -2,21 +2,32 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-var embedder = null;
+var embedder = {};
+// This will be overriden in specific tests.
+embedder.processMessage = function(data) {
+ return false;
+};
function reportConnected() {
var msg = ['connected'];
- embedder.postMessage(JSON.stringify(msg), '*');
+ embedder.channel.postMessage(JSON.stringify(msg), '*');
+}
+
+function reportError(messageType) {
+ var msg = ['error', messageType];
+ embedder.channel.postMessage(JSON.stringify(msg), '*');
}
window.addEventListener('message', function(e) {
- embedder = e.source;
+ embedder.channel = e.source;
var data = JSON.parse(e.data);
- switch (data[0]) {
- case 'connect': {
- reportConnected();
- break;
- }
+ if (data[0] == 'connect') {
+ reportConnected();
+ return;
+ }
+ if (!embedder.processMessage(data)) {
+ reportError(data[0]);
+ return;
}
});

Powered by Google App Engine
This is Rietveld 408576698