| 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 var embedder = {}; | 6 var embedder = {}; |
| 7 embedder.baseGuestURL = ''; | 7 embedder.baseGuestURL = ''; |
| 8 embedder.emptyGuestURL = ''; | 8 embedder.emptyGuestURL = ''; |
| 9 embedder.windowOpenGuestURL = ''; | 9 embedder.windowOpenGuestURL = ''; |
| 10 embedder.noReferrerGuestURL = ''; | 10 embedder.noReferrerGuestURL = ''; |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 webview.addEventListener('loadabort', function(e) { | 423 webview.addEventListener('loadabort', function(e) { |
| 424 embedder.test.fail(); | 424 embedder.test.fail(); |
| 425 }); | 425 }); |
| 426 webview.addEventListener('loadstop', function(e) { | 426 webview.addEventListener('loadstop', function(e) { |
| 427 embedder.test.succeed(); | 427 embedder.test.succeed(); |
| 428 }); | 428 }); |
| 429 webview.setAttribute('src', 'guest_with_inline_script.html'); | 429 webview.setAttribute('src', 'guest_with_inline_script.html'); |
| 430 document.body.appendChild(webview); | 430 document.body.appendChild(webview); |
| 431 } | 431 } |
| 432 | 432 |
| 433 // This test verifies that guests are blocked from navigating the webview to a |
| 434 // data URL. |
| 435 function testContentInitiatedNavigationToDataUrlBlocked() { |
| 436 var navUrl = "data:text/html,foo"; |
| 437 var webview = document.createElement('webview'); |
| 438 webview.addEventListener('consolemessage', function(e) { |
| 439 if (e.message.startsWith( |
| 440 'Not allowed to top-level navigate to resource:')) { |
| 441 embedder.test.succeed(); |
| 442 } |
| 443 }); |
| 444 webview.addEventListener('loadstop', function(e) { |
| 445 if (webview.getAttribute('src') == navUrl) { |
| 446 embedder.test.fail(); |
| 447 } |
| 448 }); |
| 449 webview.setAttribute('src', |
| 450 'data:text/html,<script>window.location.href = "' + navUrl + |
| 451 '";</scr' + 'ipt>'); |
| 452 document.body.appendChild(webview); |
| 453 } |
| 454 |
| 433 // Tests that a <webview> that starts with "display: none" style loads | 455 // Tests that a <webview> that starts with "display: none" style loads |
| 434 // properly. | 456 // properly. |
| 435 function testDisplayNoneWebviewLoad() { | 457 function testDisplayNoneWebviewLoad() { |
| 436 var webview = document.createElement('webview'); | 458 var webview = document.createElement('webview'); |
| 437 var visible = false; | 459 var visible = false; |
| 438 webview.style.display = 'none'; | 460 webview.style.display = 'none'; |
| 439 // foobar is a privileged partition according to the manifest file. | 461 // foobar is a privileged partition according to the manifest file. |
| 440 webview.partition = 'foobar'; | 462 webview.partition = 'foobar'; |
| 441 webview.addEventListener('loadabort', function(e) { | 463 webview.addEventListener('loadabort', function(e) { |
| 442 embedder.test.fail(); | 464 embedder.test.fail(); |
| (...skipping 2602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3045 embedder.test.testList = { | 3067 embedder.test.testList = { |
| 3046 'testAllowTransparencyAttribute': testAllowTransparencyAttribute, | 3068 'testAllowTransparencyAttribute': testAllowTransparencyAttribute, |
| 3047 'testAutosizeHeight': testAutosizeHeight, | 3069 'testAutosizeHeight': testAutosizeHeight, |
| 3048 'testAutosizeAfterNavigation': testAutosizeAfterNavigation, | 3070 'testAutosizeAfterNavigation': testAutosizeAfterNavigation, |
| 3049 'testAutosizeBeforeNavigation': testAutosizeBeforeNavigation, | 3071 'testAutosizeBeforeNavigation': testAutosizeBeforeNavigation, |
| 3050 'testAutosizeRemoveAttributes': testAutosizeRemoveAttributes, | 3072 'testAutosizeRemoveAttributes': testAutosizeRemoveAttributes, |
| 3051 'testAutosizeWithPartialAttributes': testAutosizeWithPartialAttributes, | 3073 'testAutosizeWithPartialAttributes': testAutosizeWithPartialAttributes, |
| 3052 'testAPIMethodExistence': testAPIMethodExistence, | 3074 'testAPIMethodExistence': testAPIMethodExistence, |
| 3053 'testChromeExtensionURL': testChromeExtensionURL, | 3075 'testChromeExtensionURL': testChromeExtensionURL, |
| 3054 'testChromeExtensionRelativePath': testChromeExtensionRelativePath, | 3076 'testChromeExtensionRelativePath': testChromeExtensionRelativePath, |
| 3077 'testContentInitiatedNavigationToDataUrlBlocked': |
| 3078 testContentInitiatedNavigationToDataUrlBlocked, |
| 3055 'testDisplayNoneWebviewLoad': testDisplayNoneWebviewLoad, | 3079 'testDisplayNoneWebviewLoad': testDisplayNoneWebviewLoad, |
| 3056 'testDisplayNoneWebviewRemoveChild': testDisplayNoneWebviewRemoveChild, | 3080 'testDisplayNoneWebviewRemoveChild': testDisplayNoneWebviewRemoveChild, |
| 3057 'testInlineScriptFromAccessibleResources': | 3081 'testInlineScriptFromAccessibleResources': |
| 3058 testInlineScriptFromAccessibleResources, | 3082 testInlineScriptFromAccessibleResources, |
| 3059 'testInvalidChromeExtensionURL': testInvalidChromeExtensionURL, | 3083 'testInvalidChromeExtensionURL': testInvalidChromeExtensionURL, |
| 3060 'testWebRequestAPIExistence': testWebRequestAPIExistence, | 3084 'testWebRequestAPIExistence': testWebRequestAPIExistence, |
| 3061 'testWebRequestAPIAddListener': testWebRequestAPIAddListener, | 3085 'testWebRequestAPIAddListener': testWebRequestAPIAddListener, |
| 3062 'testEventName': testEventName, | 3086 'testEventName': testEventName, |
| 3063 'testOnEventProperties': testOnEventProperties, | 3087 'testOnEventProperties': testOnEventProperties, |
| 3064 'testLoadProgressEvent': testLoadProgressEvent, | 3088 'testLoadProgressEvent': testLoadProgressEvent, |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3158 testRendererNavigationRedirectWhileUnattached, | 3182 testRendererNavigationRedirectWhileUnattached, |
| 3159 'testBlobURL': testBlobURL | 3183 'testBlobURL': testBlobURL |
| 3160 }; | 3184 }; |
| 3161 | 3185 |
| 3162 onload = function() { | 3186 onload = function() { |
| 3163 chrome.test.getConfig(function(config) { | 3187 chrome.test.getConfig(function(config) { |
| 3164 embedder.setUp_(config); | 3188 embedder.setUp_(config); |
| 3165 chrome.test.sendMessage("Launched"); | 3189 chrome.test.sendMessage("Launched"); |
| 3166 }); | 3190 }); |
| 3167 }; | 3191 }; |
| OLD | NEW |