| Index: chrome/test/data/extensions/platform_apps/iframes/main.js
|
| diff --git a/chrome/test/data/extensions/platform_apps/iframes/main.js b/chrome/test/data/extensions/platform_apps/iframes/main.js
|
| index 4634b7252beb35b8c7c8feb4f85d36c5663848b2..7d47a4affd7ffe11405b51187d9cf2408b49aea2 100644
|
| --- a/chrome/test/data/extensions/platform_apps/iframes/main.js
|
| +++ b/chrome/test/data/extensions/platform_apps/iframes/main.js
|
| @@ -8,30 +8,55 @@ chrome.test.getConfig(function(config) {
|
| var REMOTE_URL = 'http://localhost:' + config.testServer.port
|
| '/extensions/platform_apps/iframes/remote-iframe.html';
|
|
|
| + function onEvent(target, event_name) {
|
| + return new Promise((resolve, reject) => {
|
| + target.addEventListener(event_name, resolve);
|
| + });
|
| + }
|
| +
|
| + function onCspViolation(url) {
|
| + return onEvent(window, 'securitypolicyviolation').then(event => {
|
| + chrome.test.assertEq(url, event.blockedURI);
|
| + });
|
| + }
|
| +
|
| chrome.test.runTests([
|
| function localIframe() {
|
| var iframe = document.createElement('iframe');
|
| - iframe.onload = chrome.test.callbackPass(function() {
|
| + iframe.src = LOCAL_URL;
|
| +
|
| + // Expect this to load normally.
|
| + onEvent(iframe, 'load').then(() => {
|
| console.log('Local iframe loaded');
|
| + chrome.test.succeed();
|
| });
|
| - iframe.src = LOCAL_URL;
|
| +
|
| document.body.appendChild(iframe);
|
| },
|
|
|
| function dataUrlIframe() {
|
| var iframe = document.createElement('iframe');
|
| - iframe.onload = chrome.test.callbackPass(function() {
|
| + iframe.src = DATA_URL;
|
| +
|
| + // Expect this to load normally.
|
| + onEvent(iframe, 'load').then(() => {
|
| console.log('data: URL iframe loaded');
|
| + chrome.test.succeed();
|
| });
|
| - iframe.src = DATA_URL;
|
| +
|
| document.body.appendChild(iframe);
|
| },
|
|
|
| function filesystemUrlIframe() {
|
| var iframe = document.createElement('iframe');
|
| - iframe.onload = chrome.test.callbackPass(function() {
|
| - console.log('filesystem: URL iframe loaded');
|
| - });
|
| +
|
| + // The filesystem: document should load and postMessage back.
|
| + Promise.all([onEvent(iframe, 'load'), onEvent(window, 'message')])
|
| + .then(chrome.test.succeed);
|
| +
|
| + var blob = new Blob(['This filesystem: frame should be displayed',
|
| + '<script src="', document.origin, '/post_to_parent.js"></scri',
|
| + 'pt>'], {type: 'text/html'});
|
|
|
| webkitRequestFileSystem(
|
| window.TEMPORARY,
|
| @@ -49,8 +74,6 @@ chrome.test.getConfig(function(config) {
|
| document.body.appendChild(iframe);
|
| };
|
|
|
| - var blob = new Blob(['This frame should be displayed'],
|
| - {type: 'text/html'});
|
| fileWriter.write(blob);
|
| });
|
| });
|
| @@ -58,13 +81,17 @@ chrome.test.getConfig(function(config) {
|
| },
|
|
|
| function blobUrlIframe() {
|
| - var blob = new Blob(['This frame should be displayed'],
|
| - {type: 'text/html'});
|
| - var blobUrl = window.URL.createObjectURL(blob);
|
| var iframe = document.createElement('iframe');
|
| - iframe.onload = chrome.test.callbackPass(function() {
|
| - console.log('blob: URL iframe loaded');
|
| - });
|
| +
|
| + // The blob: document should load and postMessage back.
|
| + Promise.all([onEvent(iframe, 'load'), onEvent(window, 'message')])
|
| + .then(chrome.test.succeed);
|
| +
|
| + var blob = new Blob(['This blob: frame should be displayed',
|
| + '<script src="', document.origin, '/post_to_parent.js"></scri',
|
| + 'pt>'], {type: 'text/html'});
|
| + var blobUrl = window.URL.createObjectURL(blob);
|
| +
|
| iframe.src = blobUrl;
|
| document.body.appendChild(iframe);
|
| },
|
| @@ -72,11 +99,11 @@ chrome.test.getConfig(function(config) {
|
| function remoteIframe() {
|
| var iframe = document.createElement('iframe');
|
| iframe.src = REMOTE_URL;
|
| - document.body.appendChild(iframe);
|
|
|
| - // Load failure should happen synchronously, but wait a bit before
|
| - // declaring success.
|
| - setTimeout(chrome.test.succeed, 500);
|
| - }
|
| + // Expect this to be blocked by the CSP.
|
| + onCspViolation(REMOTE_URL).then(chrome.test.succeed);
|
| +
|
| + document.body.appendChild(iframe);
|
| + },
|
| ]);
|
| });
|
|
|