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