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

Side by Side Diff: chrome/test/data/extensions/api_test/sandboxed_pages_csp/main.js

Issue 2563843002: Restrict app sandbox's CSP to disallow loading web content in them. (Closed)
Patch Set: sync Created 4 years 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
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 var LOCAL_FILE_NAME = 'local_frame.html';
6 var REMOTE_FILE_NAME = 'remote_frame.html';
7
8 onmessage = function(e) {
9 var data = JSON.parse(e.data);
10 var message = data[0];
11 if (message != 'loaded')
12 return;
13
14 var loadedFileName = data[1];
15 var succeeded = data[2];
16 var expectSuccess = loadedFileName === LOCAL_FILE_NAME;
17 if (expectSuccess === succeeded) {
18 chrome.test.succeed();
Devlin 2016/12/15 00:04:11 optional: we could just do chrome.test.assertEq(ex
lazyboy 2016/12/15 08:02:35 Done.
19 } else {
20 chrome.test.fail();
21 }
22 };
23
24 var loadIframeContentInSandboxedPage = function(url, fileName) {
25 var sandboxedFrame = document.createElement('iframe');
26 sandboxedFrame.src = 'sandboxed.html';
27 sandboxedFrame.onload = function() {
28 sandboxedFrame.contentWindow.postMessage(
29 JSON.stringify(['load', url, fileName]), '*');
30 sandboxedFrame.onload = null;
31 };
32 document.body.appendChild(sandboxedFrame);
33 };
34
35 onload = function() {
36 chrome.test.getConfig(function(config) {
37 chrome.test.runTests([
38 function sandboxedFrameLocalContentPasses() {
39 // Response is received in |onmessage|.
40 loadIframeContentInSandboxedPage(LOCAL_FILE_NAME, LOCAL_FILE_NAME);
41 },
42 function sandboxedFrameWebContentFails() {
43 var url = 'http://localhost:PORT/extensions/api_test/' +
44 'sandboxed_pages_web_content/URL'.replace(
Devlin 2016/12/15 00:04:11 I've seen this pattern before, but it's kind of si
lazyboy 2016/12/15 08:02:35 Done.
45 /PORT/, config.testServer.port).replace(
46 /URL/, REMOTE_FILE_NAME);
47 // Response is received in |onmessage|.
48 loadIframeContentInSandboxedPage(url, REMOTE_FILE_NAME);
49 }
50 ]);
51 });
52 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698