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 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 // on the <webview> tag. | 572 // on the <webview> tag. |
573 webview.addEventListener('loadcommit', onLoadCommitA); | 573 webview.addEventListener('loadcommit', onLoadCommitA); |
574 webview.addEventListener('loadcommit', onLoadCommitB); | 574 webview.addEventListener('loadcommit', onLoadCommitB); |
575 webview.setAttribute('src', url); | 575 webview.setAttribute('src', url); |
576 } | 576 } |
577 | 577 |
578 // This test verifies that setting the partition attribute after the src has | 578 // This test verifies that setting the partition attribute after the src has |
579 // been set raises an exception. | 579 // been set raises an exception. |
580 function testPartitionRaisesException() { | 580 function testPartitionRaisesException() { |
581 var webview = document.createElement('webview'); | 581 var webview = document.createElement('webview'); |
582 webview.setAttribute('partition', arguments.callee.name); | 582 var partitionAttribute = arguments.callee.name; |
| 583 webview.setAttribute('partition', partitionAttribute); |
583 | 584 |
584 var loadstopHandler = function(e) { | 585 var loadstopHandler = function(e) { |
585 try { | 586 try { |
586 webview.partition = 'illegal'; | 587 webview.partition = 'illegal'; |
587 embedder.test.fail(); | 588 embedder.test.fail(); |
588 } catch (e) { | 589 } catch (e) { |
| 590 embedder.test.assertEq(partitionAttribute, webview.partition); |
589 embedder.test.succeed(); | 591 embedder.test.succeed(); |
590 } | 592 } |
591 }; | 593 }; |
592 webview.addEventListener('loadstop', loadstopHandler); | 594 webview.addEventListener('loadstop', loadstopHandler); |
593 | 595 |
594 document.body.appendChild(webview); | 596 document.body.appendChild(webview); |
595 webview.setAttribute('src', 'data:text/html,trigger navigation'); | 597 webview.setAttribute('src', 'data:text/html,trigger navigation'); |
596 } | 598 } |
597 | 599 |
| 600 // This test verifies that removing partition attribute after navigation does |
| 601 // not work, i.e. the partition remains the same. |
| 602 function testPartitionRemovalAfterNavigationFails() { |
| 603 var webview = document.createElement('webview'); |
| 604 document.body.appendChild(webview); |
| 605 |
| 606 var partition = 'testme'; |
| 607 webview.setAttribute('partition', partition); |
| 608 |
| 609 var loadstopHandler = function(e) { |
| 610 window.console.log('webview.loadstop'); |
| 611 // Removing after navigation should not change the partition. |
| 612 webview.removeAttribute('partition'); |
| 613 embedder.test.assertEq('testme', webview.partition); |
| 614 embedder.test.succeed(); |
| 615 }; |
| 616 webview.addEventListener('loadstop', loadstopHandler); |
| 617 |
| 618 webview.setAttribute('src', 'data:text/html,<html><body>guest</body></html>'); |
| 619 } |
| 620 |
598 function testExecuteScriptFail() { | 621 function testExecuteScriptFail() { |
599 var webview = document.createElement('webview'); | 622 var webview = document.createElement('webview'); |
600 document.body.appendChild(webview); | 623 document.body.appendChild(webview); |
601 setTimeout(function() { | 624 setTimeout(function() { |
602 try { | 625 try { |
603 webview.executeScript( | 626 webview.executeScript( |
604 {code:'document.body.style.backgroundColor = "red";'}, | 627 {code:'document.body.style.backgroundColor = "red";'}, |
605 function(results) { | 628 function(results) { |
606 embedder.test.fail(); | 629 embedder.test.fail(); |
607 }); | 630 }); |
(...skipping 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1680 'testInlineScriptFromAccessibleResources': | 1703 'testInlineScriptFromAccessibleResources': |
1681 testInlineScriptFromAccessibleResources, | 1704 testInlineScriptFromAccessibleResources, |
1682 'testInvalidChromeExtensionURL': testInvalidChromeExtensionURL, | 1705 'testInvalidChromeExtensionURL': testInvalidChromeExtensionURL, |
1683 'testWebRequestAPIExistence': testWebRequestAPIExistence, | 1706 'testWebRequestAPIExistence': testWebRequestAPIExistence, |
1684 'testEventName': testEventName, | 1707 'testEventName': testEventName, |
1685 'testOnEventProperties': testOnEventProperties, | 1708 'testOnEventProperties': testOnEventProperties, |
1686 'testLoadProgressEvent': testLoadProgressEvent, | 1709 'testLoadProgressEvent': testLoadProgressEvent, |
1687 'testDestroyOnEventListener': testDestroyOnEventListener, | 1710 'testDestroyOnEventListener': testDestroyOnEventListener, |
1688 'testCannotMutateEventName': testCannotMutateEventName, | 1711 'testCannotMutateEventName': testCannotMutateEventName, |
1689 'testPartitionRaisesException': testPartitionRaisesException, | 1712 'testPartitionRaisesException': testPartitionRaisesException, |
| 1713 'testPartitionRemovalAfterNavigationFails': |
| 1714 testPartitionRemovalAfterNavigationFails, |
1690 'testExecuteScriptFail': testExecuteScriptFail, | 1715 'testExecuteScriptFail': testExecuteScriptFail, |
1691 'testExecuteScript': testExecuteScript, | 1716 'testExecuteScript': testExecuteScript, |
1692 'testExecuteScriptIsAbortedWhenWebViewSourceIsChanged': | 1717 'testExecuteScriptIsAbortedWhenWebViewSourceIsChanged': |
1693 testExecuteScriptIsAbortedWhenWebViewSourceIsChanged, | 1718 testExecuteScriptIsAbortedWhenWebViewSourceIsChanged, |
1694 'testTerminateAfterExit': testTerminateAfterExit, | 1719 'testTerminateAfterExit': testTerminateAfterExit, |
1695 'testAssignSrcAfterCrash': testAssignSrcAfterCrash, | 1720 'testAssignSrcAfterCrash': testAssignSrcAfterCrash, |
1696 'testNavOnConsecutiveSrcAttributeChanges': | 1721 'testNavOnConsecutiveSrcAttributeChanges': |
1697 testNavOnConsecutiveSrcAttributeChanges, | 1722 testNavOnConsecutiveSrcAttributeChanges, |
1698 'testNavOnSrcAttributeChange': testNavOnSrcAttributeChange, | 1723 'testNavOnSrcAttributeChange': testNavOnSrcAttributeChange, |
1699 'testReassignSrcAttribute': testReassignSrcAttribute, | 1724 'testReassignSrcAttribute': testReassignSrcAttribute, |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1735 'testFindAPI': testFindAPI, | 1760 'testFindAPI': testFindAPI, |
1736 'testFindAPI_findupdate': testFindAPI | 1761 'testFindAPI_findupdate': testFindAPI |
1737 }; | 1762 }; |
1738 | 1763 |
1739 onload = function() { | 1764 onload = function() { |
1740 chrome.test.getConfig(function(config) { | 1765 chrome.test.getConfig(function(config) { |
1741 embedder.setUp_(config); | 1766 embedder.setUp_(config); |
1742 chrome.test.sendMessage("Launched"); | 1767 chrome.test.sendMessage("Launched"); |
1743 }); | 1768 }); |
1744 }; | 1769 }; |
OLD | NEW |