| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 var util = {}; | 5 var util = {}; |
| 6 | 6 |
| 7 // Creates a <webview> tag in document.body and returns the reference to it. | 7 // Creates a <webview> tag in document.body and returns the reference to it. |
| 8 // It also sets a dummy src. The dummy src is significant because this makes | 8 // It also sets a dummy src. The dummy src is significant because this makes |
| 9 // sure that the <object> shim is created (asynchronously at this point) for the | 9 // sure that the <object> shim is created (asynchronously at this point) for the |
| 10 // <webview> tag. This makes the <webview> tag ready for add/removeEventListener | 10 // <webview> tag. This makes the <webview> tag ready for add/removeEventListener |
| 11 // calls. | 11 // calls. |
| 12 util.createWebViewTagInDOM = function(partitionName) { | 12 util.createWebViewTagInDOM = function(partitionName) { |
| 13 var webview = document.createElement('webview'); | 13 var webview = document.createElement('webview'); |
| 14 webview.style.width = '300px'; | 14 webview.style.width = '300px'; |
| 15 webview.style.height = '200px'; | 15 webview.style.height = '200px'; |
| 16 var urlDummy = 'data:text/html,<body>Initial dummy guest</body>'; | 16 var urlDummy = 'data:text/html,<body>Initial dummy guest</body>'; |
| 17 webview.setAttribute('src', urlDummy); | 17 webview.setAttribute('src', urlDummy); |
| 18 webview.setAttribute('partition', partitionName); | 18 webview.setAttribute('partition', partitionName); |
| 19 document.body.appendChild(webview); | 19 document.body.appendChild(webview); |
| 20 return webview; | 20 return webview; |
| 21 }; | 21 }; |
| 22 | 22 |
| 23 chrome.test.getConfig(function(config) { | 23 chrome.test.getConfig(function(config) { |
| 24 var windowOpenGuestURL = 'http://localhost:' + config.testServer.port + | 24 var windowOpenGuestURL = 'http://localhost:' + config.testServer.port + |
| 25 '/files/extensions/platform_apps/web_view/shim/guest.html'; | 25 '/extensions/platform_apps/web_view/shim/guest.html'; |
| 26 var noReferrerGuestURL = 'http://localhost:' + config.testServer.port + | 26 var noReferrerGuestURL = 'http://localhost:' + config.testServer.port + |
| 27 '/files/extensions/platform_apps/web_view/shim/guest_noreferrer.html'; | 27 '/extensions/platform_apps/web_view/shim/guest_noreferrer.html'; |
| 28 chrome.test.runTests([ | 28 chrome.test.runTests([ |
| 29 function webView() { | 29 function webView() { |
| 30 var webview = document.querySelector('webview'); | 30 var webview = document.querySelector('webview'); |
| 31 // Since we can't currently inspect the page loaded inside the <webview>, | 31 // Since we can't currently inspect the page loaded inside the <webview>, |
| 32 // the only way we can check that the shim is working is by changing the | 32 // the only way we can check that the shim is working is by changing the |
| 33 // size and seeing if the shim updates the size of the DOM. | 33 // size and seeing if the shim updates the size of the DOM. |
| 34 chrome.test.assertEq(300, webview.offsetWidth); | 34 chrome.test.assertEq(300, webview.offsetWidth); |
| 35 chrome.test.assertEq(200, webview.offsetHeight); | 35 chrome.test.assertEq(200, webview.offsetHeight); |
| 36 | 36 |
| 37 webview.style.width = '310px'; | 37 webview.style.width = '310px'; |
| (...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 webview.onBeforeRequest.addListener(function(e) { | 435 webview.onBeforeRequest.addListener(function(e) { |
| 436 chrome.test.succeed(); | 436 chrome.test.succeed(); |
| 437 }, { urls: ['<all_urls>']}, ['blocking']) ; | 437 }, { urls: ['<all_urls>']}, ['blocking']) ; |
| 438 webview.src = windowOpenGuestURL; | 438 webview.src = windowOpenGuestURL; |
| 439 }; | 439 }; |
| 440 webview.addEventListener('loadstop', firstLoad); | 440 webview.addEventListener('loadstop', firstLoad); |
| 441 document.body.appendChild(webview); | 441 document.body.appendChild(webview); |
| 442 } | 442 } |
| 443 ]); | 443 ]); |
| 444 }); | 444 }); |
| OLD | NEW |