| 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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 typeof webview.contentWindow.postMessage); | 298 typeof webview.contentWindow.postMessage); |
| 299 embedder.test.succeed(); | 299 embedder.test.succeed(); |
| 300 }); | 300 }); |
| 301 webview.setAttribute('src', 'data:text/html,webview check api'); | 301 webview.setAttribute('src', 'data:text/html,webview check api'); |
| 302 document.body.appendChild(webview); | 302 document.body.appendChild(webview); |
| 303 } | 303 } |
| 304 | 304 |
| 305 // This test verifies that the loadstop event fires when loading a webview | 305 // This test verifies that the loadstop event fires when loading a webview |
| 306 // accessible resource from a partition that is privileged. | 306 // accessible resource from a partition that is privileged. |
| 307 function testChromeExtensionURL() { | 307 function testChromeExtensionURL() { |
| 308 var localResource = chrome.runtime.getURL('guest.html'); | 308 var localResource = chrome.runtime.getURL('guest_with_inline_script.html'); |
| 309 var webview = document.createElement('webview'); | 309 var webview = document.createElement('webview'); |
| 310 // foobar is a privileged partition according to the manifest file. | 310 // foobar is a privileged partition according to the manifest file. |
| 311 webview.partition = 'foobar'; | 311 webview.partition = 'foobar'; |
| 312 webview.addEventListener('loadabort', function(e) { | 312 webview.addEventListener('loadabort', function(e) { |
| 313 embedder.test.fail(); | 313 embedder.test.fail(); |
| 314 }); | 314 }); |
| 315 webview.addEventListener('loadstop', function(e) { | 315 webview.addEventListener('loadstop', function(e) { |
| 316 embedder.test.succeed(); | 316 embedder.test.succeed(); |
| 317 }); | 317 }); |
| 318 webview.setAttribute('src', localResource); | 318 webview.setAttribute('src', localResource); |
| 319 document.body.appendChild(webview); | 319 document.body.appendChild(webview); |
| 320 } | 320 } |
| 321 | 321 |
| 322 // This test verifies that the loadstop event fires when loading a webview | 322 // This test verifies that the loadstop event fires when loading a webview |
| 323 // accessible resource from a partition that is privileged if the src URL | 323 // accessible resource from a partition that is privileged if the src URL |
| 324 // is not fully qualified. | 324 // is not fully qualified. |
| 325 function testChromeExtensionRelativePath() { | 325 function testChromeExtensionRelativePath() { |
| 326 var webview = document.createElement('webview'); | 326 var webview = document.createElement('webview'); |
| 327 // foobar is a privileged partition according to the manifest file. | 327 // foobar is a privileged partition according to the manifest file. |
| 328 webview.partition = 'foobar'; | 328 webview.partition = 'foobar'; |
| 329 webview.addEventListener('loadabort', function(e) { | 329 webview.addEventListener('loadabort', function(e) { |
| 330 embedder.test.fail(); | 330 embedder.test.fail(); |
| 331 }); | 331 }); |
| 332 webview.addEventListener('loadstop', function(e) { | 332 webview.addEventListener('loadstop', function(e) { |
| 333 embedder.test.succeed(); | 333 embedder.test.succeed(); |
| 334 }); | 334 }); |
| 335 webview.setAttribute('src', 'guest.html'); | 335 webview.setAttribute('src', 'guest_with_inline_script.html'); |
| 336 document.body.appendChild(webview); | 336 document.body.appendChild(webview); |
| 337 } | 337 } |
| 338 | 338 |
| 339 // Makes sure inline scripts works inside guest that was loaded from |
| 340 // accessible_resources. |
| 341 function testInlineScriptFromAccessibleResources() { |
| 342 var webview = document.createElement('webview'); |
| 343 // foobar is a privileged partition according to the manifest file. |
| 344 webview.partition = 'foobar'; |
| 345 webview.addEventListener('loadabort', function(e) { |
| 346 embedder.test.fail(); |
| 347 }); |
| 348 webview.addEventListener('consolemessage', function(e) { |
| 349 window.console.log('consolemessage: ' + e.message); |
| 350 if (e.message == 'guest_with_inline_script.html: Inline script ran') { |
| 351 embedder.test.succeed(); |
| 352 } |
| 353 }); |
| 354 webview.setAttribute('src', 'guest_with_inline_script.html'); |
| 355 document.body.appendChild(webview); |
| 356 } |
| 357 |
| 339 // This tests verifies that webview fires a loadabort event instead of crashing | 358 // This tests verifies that webview fires a loadabort event instead of crashing |
| 340 // the browser if we attempt to navigate to a chrome-extension: URL with an | 359 // the browser if we attempt to navigate to a chrome-extension: URL with an |
| 341 // extension ID that does not exist. | 360 // extension ID that does not exist. |
| 342 function testInvalidChromeExtensionURL() { | 361 function testInvalidChromeExtensionURL() { |
| 343 var invalidResource = 'chrome-extension://abc123/guest.html'; | 362 var invalidResource = 'chrome-extension://abc123/guest.html'; |
| 344 var webview = document.createElement('webview'); | 363 var webview = document.createElement('webview'); |
| 345 // foobar is a privileged partition according to the manifest file. | 364 // foobar is a privileged partition according to the manifest file. |
| 346 webview.partition = 'foobar'; | 365 webview.partition = 'foobar'; |
| 347 webview.addEventListener('loadabort', function(e) { | 366 webview.addEventListener('loadabort', function(e) { |
| 348 embedder.test.succeed(); | 367 embedder.test.succeed(); |
| (...skipping 1146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1495 }; | 1514 }; |
| 1496 | 1515 |
| 1497 embedder.test.testList = { | 1516 embedder.test.testList = { |
| 1498 'testAutosizeAfterNavigation': testAutosizeAfterNavigation, | 1517 'testAutosizeAfterNavigation': testAutosizeAfterNavigation, |
| 1499 'testAutosizeBeforeNavigation': testAutosizeBeforeNavigation, | 1518 'testAutosizeBeforeNavigation': testAutosizeBeforeNavigation, |
| 1500 'testAutosizeRemoveAttributes': testAutosizeRemoveAttributes, | 1519 'testAutosizeRemoveAttributes': testAutosizeRemoveAttributes, |
| 1501 'testAutosizeWithPartialAttributes': testAutosizeWithPartialAttributes, | 1520 'testAutosizeWithPartialAttributes': testAutosizeWithPartialAttributes, |
| 1502 'testAPIMethodExistence': testAPIMethodExistence, | 1521 'testAPIMethodExistence': testAPIMethodExistence, |
| 1503 'testChromeExtensionURL': testChromeExtensionURL, | 1522 'testChromeExtensionURL': testChromeExtensionURL, |
| 1504 'testChromeExtensionRelativePath': testChromeExtensionRelativePath, | 1523 'testChromeExtensionRelativePath': testChromeExtensionRelativePath, |
| 1524 'testInlineScriptFromAccessibleResources': |
| 1525 testInlineScriptFromAccessibleResources, |
| 1505 'testInvalidChromeExtensionURL': testInvalidChromeExtensionURL, | 1526 'testInvalidChromeExtensionURL': testInvalidChromeExtensionURL, |
| 1506 'testWebRequestAPIExistence': testWebRequestAPIExistence, | 1527 'testWebRequestAPIExistence': testWebRequestAPIExistence, |
| 1507 'testEventName': testEventName, | 1528 'testEventName': testEventName, |
| 1508 'testOnEventProperties': testOnEventProperties, | 1529 'testOnEventProperties': testOnEventProperties, |
| 1509 'testLoadProgressEvent': testLoadProgressEvent, | 1530 'testLoadProgressEvent': testLoadProgressEvent, |
| 1510 'testDestroyOnEventListener': testDestroyOnEventListener, | 1531 'testDestroyOnEventListener': testDestroyOnEventListener, |
| 1511 'testCannotMutateEventName': testCannotMutateEventName, | 1532 'testCannotMutateEventName': testCannotMutateEventName, |
| 1512 'testPartitionRaisesException': testPartitionRaisesException, | 1533 'testPartitionRaisesException': testPartitionRaisesException, |
| 1513 'testExecuteScriptFail': testExecuteScriptFail, | 1534 'testExecuteScriptFail': testExecuteScriptFail, |
| 1514 'testExecuteScript': testExecuteScript, | 1535 'testExecuteScript': testExecuteScript, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1552 'testFindAPI': testFindAPI, | 1573 'testFindAPI': testFindAPI, |
| 1553 'testFindAPI_findupdate': testFindAPI | 1574 'testFindAPI_findupdate': testFindAPI |
| 1554 }; | 1575 }; |
| 1555 | 1576 |
| 1556 onload = function() { | 1577 onload = function() { |
| 1557 chrome.test.getConfig(function(config) { | 1578 chrome.test.getConfig(function(config) { |
| 1558 embedder.setUp_(config); | 1579 embedder.setUp_(config); |
| 1559 chrome.test.sendMessage("Launched"); | 1580 chrome.test.sendMessage("Launched"); |
| 1560 }); | 1581 }); |
| 1561 }; | 1582 }; |
| OLD | NEW |