OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 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 '/files/extensions/platform_apps/iframes/remote-iframe.html'; |
| 10 |
| 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'); |
| 16 }); |
| 17 iframe.src = LOCAL_URL; |
| 18 document.body.appendChild(iframe); |
| 19 }, |
| 20 |
| 21 function dataUrlIframe() { |
| 22 var iframe = document.createElement('iframe'); |
| 23 iframe.onload = chrome.test.callbackPass(function() { |
| 24 console.log('data: URL iframe loaded'); |
| 25 }); |
| 26 iframe.src = DATA_URL; |
| 27 document.body.appendChild(iframe); |
| 28 }, |
| 29 |
| 30 function filesystemUrlIframe() { |
| 31 var iframe = document.createElement('iframe'); |
| 32 iframe.onload = chrome.test.callbackPass(function() { |
| 33 console.log('filesystem: URL iframe loaded'); |
| 34 }); |
| 35 |
| 36 webkitRequestFileSystem( |
| 37 window.TEMPORARY, |
| 38 1024, |
| 39 function(fs) { |
| 40 fs.root.getFile( |
| 41 'test.html', |
| 42 {create: true, exclusive: false}, |
| 43 function(fileEntry) { |
| 44 fileEntry.createWriter(function(fileWriter) { |
| 45 fileWriter.onwriteend = function(e) { |
| 46 var url = fileEntry.toURL(); |
| 47 chrome.test.assertEq(0, url.indexOf('filesystem:')); |
| 48 iframe.src = url; |
| 49 document.body.appendChild(iframe); |
| 50 }; |
| 51 |
| 52 var blobBuilder = new WebKitBlobBuilder(); |
| 53 blobBuilder.append('This frame should be displayed'); |
| 54 fileWriter.write(blobBuilder.getBlob('text/html')); |
| 55 }); |
| 56 }); |
| 57 }); |
| 58 }, |
| 59 |
| 60 function blobUrlIframe() { |
| 61 var blobBuilder = new WebKitBlobBuilder(); |
| 62 blobBuilder.append('This frame should be displayed'); |
| 63 |
| 64 var blobUrl = window.webkitURL.createObjectURL( |
| 65 blobBuilder.getBlob('text/html')); |
| 66 var iframe = document.createElement('iframe'); |
| 67 iframe.onload = chrome.test.callbackPass(function() { |
| 68 console.log('blob: URL iframe loaded'); |
| 69 }); |
| 70 iframe.src = blobUrl; |
| 71 document.body.appendChild(iframe); |
| 72 }, |
| 73 |
| 74 function FAILS_remoteIframe() { |
| 75 // TODO(mihaip): re-enable once remote iframe restrictions are |
| 76 // implemented. |
| 77 chrome.test.succeed(); |
| 78 return; |
| 79 |
| 80 var iframe = document.createElement('iframe'); |
| 81 iframe.onload = function() { |
| 82 chrome.test.notifyFail('Remote iframe should not have loaded'); |
| 83 }; |
| 84 iframe.src = REMOTE_URL; |
| 85 document.body.appendChild(iframe); |
| 86 |
| 87 // Load failure should happen synchronously, but wait a bit before |
| 88 // declaring success. |
| 89 setTimeout(chrome.test.succeed, 500); |
| 90 } |
| 91 ]); |
| 92 }); |
OLD | NEW |