1 // Copyright (c) 2012 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.
5 chrome.test.getConfig(function(config) {
6 var LOCAL_URL = 'local-iframe.html';
7 var DATA_URL = 'data:text/plain,This frame should be displayed.';
8 var REMOTE_URL = 'http://localhost:' + config.testServer.port
9 '/extensions/platform_apps/iframes/remote-iframe.html';
11 chrome.test.runTests([
12 function localIframe() {
13 var iframe = document.createElement('iframe');
14 iframe.onload = chrome.test.callbackPass(function() {
15 console.log('Local iframe loaded');
17 iframe.src = LOCAL_URL;
18 document.body.appendChild(iframe);
21 function dataUrlIframe() {
22 var iframe = document.createElement('iframe');
23 iframe.onload = chrome.test.callbackPass(function() {
24 console.log('data: URL iframe loaded');
26 iframe.src = DATA_URL;
27 document.body.appendChild(iframe);
30 function filesystemUrlIframe() {
31 var iframe = document.createElement('iframe');
32 iframe.onload = chrome.test.callbackPass(function() {
33 console.log('filesystem: URL iframe loaded');
36 webkitRequestFileSystem(
42 {create: true, exclusive: false},
44 fileEntry.createWriter(function(fileWriter) {
45 fileWriter.onwriteend = function(e) {
46 var url = fileEntry.toURL();
47 chrome.test.assertEq(0, url.indexOf('filesystem:'));
49 document.body.appendChild(iframe);
52 var blob = new Blob(['This frame should be displayed'],
54 fileWriter.write(blob);
60 function blobUrlIframe() {
61 var blob = new Blob(['This frame should be displayed'],
63 var blobUrl = window.URL.createObjectURL(blob);
64 var iframe = document.createElement('iframe');
65 iframe.onload = chrome.test.callbackPass(function() {
66 console.log('blob: URL iframe loaded');
69 document.body.appendChild(iframe);
72 function remoteIframe() {
73 var iframe = document.createElement('iframe');
74 iframe.src = REMOTE_URL;
75 document.body.appendChild(iframe);
77 // Load failure should happen synchronously, but wait a bit before
79 setTimeout(chrome.test.succeed, 500);