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

Unified Diff: chrome/test/data/extensions/platform_apps/web_view/content_script_fetch/content_script.js

Issue 2803963002: Don't kill Chrome Apps that make XHRs from guests. (Closed)
Patch Set: Fix comments from review. Created 3 years, 8 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/content_script_fetch/content_script.js
diff --git a/chrome/test/data/extensions/platform_apps/web_view/content_script_fetch/content_script.js b/chrome/test/data/extensions/platform_apps/web_view/content_script_fetch/content_script.js
new file mode 100644
index 0000000000000000000000000000000000000000..b5258cbc8fadabf63f3239d55d29b267ca442e38
--- /dev/null
+++ b/chrome/test/data/extensions/platform_apps/web_view/content_script_fetch/content_script.js
@@ -0,0 +1,30 @@
+// Copyright 2017 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.
+
+var embedder = null;
+
+function reportResult(result) {
+ var msg = ['fetch-' + result];
+ embedder.postMessage(JSON.stringify(msg), '*');
+}
+
+window.addEventListener('message', function(e) {
+ embedder = e.source;
+ var data = JSON.parse(e.data);
+ if (data[0] == 'start-fetch') {
+ fetch('http://127.0.0.1:' + location.port + '/extensions/xhr.txt')
+ .then((result) => result.text())
+ .then((text) => {
+ reportResult(
+ (text == 'File to request via XHR.\n') ? 'success' : 'failure');
+ })
+ .catch(err => {
+ reportResult('failure');
+ });
+ } else {
+ reportResult('unexpected-message');
+ }
+});
+
+window.console.log('Script has been successfully injected.');

Powered by Google App Engine
This is Rietveld 408576698