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

Side by Side Diff: chrome/test/data/extensions/api_test/sandboxed_pages_csp/sandboxed.html

Issue 2563843002: Restrict app sandbox's CSP to disallow loading web content in them. (Closed)
Patch Set: address comments + rework CL + StringPieces 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 This page should be sandboxed.
2
3 <script>
4 // We're not served with the extension default CSP, we can use inline script.
5
6 // Loading status of frames, keyed by frame's url.
7 var frameLoadStatus = {};
8
9 var updateFrameLoadStatus = function(fileName, succeeded) {
10 if (frameLoadStatus[fileName].completed)
11 return;
12 frameLoadStatus[fileName].completed = true;
13 var mainWindow = window.opener || window.top;
14 mainWindow.postMessage(JSON.stringify(['loaded', url, succeeded]), '*');
15 };
16
17 var loadIframe = function(url, fileName) {
18 var iframe = document.createElement('iframe');
19 iframe.src = url;
20 frameLoadStatus[fileName] = {completed: false};
21 document.body.appendChild(iframe);
22 // The frame load will fail for remote frames in this test because of CSP.
23 // I couldn't find a better way than setTimeout to detect that :(.
Devlin 2016/12/20 17:36:38 Can we verify this in the C++ instead? Timeouts i
lazyboy 2016/12/22 03:07:29 I've changed to test a bit to not rely on timeouts
24 setTimeout(function() {
25 updateFrameLoadStatus(fileName, false);
26 }, 2000);
27 };
28
29 onmessage = function(e) {
30 var command = JSON.parse(e.data);
31 switch (command[0]) {
32 case 'load':
33 // message from main app window.
34 url = command[1];
35 fileName = command[2];
36 loadIframe(url, fileName);
37 break;
38 case 'loaded':
39 // message from subframe.
40 fileName = command[1];
41 updateFrameLoadStatus(fileName, true);
42 break;
43 }
44 };
45 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698