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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 | 90 |
91 embedder.test.assertFalse = function(condition) { | 91 embedder.test.assertFalse = function(condition) { |
92 if (condition) { | 92 if (condition) { |
93 console.log('assertion failed: false != ' + condition); | 93 console.log('assertion failed: false != ' + condition); |
94 embedder.test.fail(); | 94 embedder.test.fail(); |
95 } | 95 } |
96 }; | 96 }; |
97 | 97 |
98 // Tests begin. | 98 // Tests begin. |
99 | 99 |
100 // This test verifies that the allowtransparency property cannot be changed | 100 // This test verifies that the allowtransparency property is interpreted as true |
101 // once set. The attribute can only be deleted. | 101 // if it exists (regardless of its value), and can be removed by setting it to |
| 102 // to anything false. |
102 function testAllowTransparencyAttribute() { | 103 function testAllowTransparencyAttribute() { |
103 var webview = document.createElement('webview'); | 104 var webview = document.createElement('webview'); |
104 webview.src = 'data:text/html,webview test'; | 105 webview.src = 'data:text/html,webview test'; |
| 106 embedder.test.assertFalse(webview.hasAttribute('allowtransparency')); |
| 107 embedder.test.assertFalse(webview.allowtransparency); |
105 webview.allowtransparency = true; | 108 webview.allowtransparency = true; |
106 | 109 |
107 webview.addEventListener('loadstop', function(e) { | 110 webview.addEventListener('loadstop', function(e) { |
108 embedder.test.assertTrue(webview.hasAttribute('allowtransparency')); | 111 embedder.test.assertTrue(webview.hasAttribute('allowtransparency')); |
| 112 embedder.test.assertTrue(webview.allowtransparency); |
109 webview.allowtransparency = false; | 113 webview.allowtransparency = false; |
| 114 embedder.test.assertFalse(webview.hasAttribute('allowtransparency')); |
| 115 embedder.test.assertFalse(webview.allowtransparency); |
| 116 webview.allowtransparency = ''; |
| 117 embedder.test.assertFalse(webview.hasAttribute('allowtransparency')); |
| 118 embedder.test.assertFalse(webview.allowtransparency); |
| 119 webview.allowtransparency = 'some string'; |
| 120 embedder.test.assertTrue(webview.hasAttribute('allowtransparency')); |
110 embedder.test.assertTrue(webview.allowtransparency); | 121 embedder.test.assertTrue(webview.allowtransparency); |
111 embedder.test.assertTrue(webview.hasAttribute('allowtransparency')); | |
112 webview.removeAttribute('allowtransparency'); | |
113 embedder.test.assertFalse(webview.allowtransparency); | |
114 embedder.test.succeed(); | 122 embedder.test.succeed(); |
115 }); | 123 }); |
116 | 124 |
117 document.body.appendChild(webview); | 125 document.body.appendChild(webview); |
118 } | 126 } |
119 | 127 |
120 // This test verifies that a lengthy page with autosize enabled will report | 128 // This test verifies that a lengthy page with autosize enabled will report |
121 // the correct height in the sizechanged event. | 129 // the correct height in the sizechanged event. |
122 function testAutosizeHeight() { | 130 function testAutosizeHeight() { |
123 var webview = document.createElement('webview'); | 131 var webview = document.createElement('webview'); |
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 | 617 |
610 webview.setAttribute('src', 'data:text/html,trigger navigation'); | 618 webview.setAttribute('src', 'data:text/html,trigger navigation'); |
611 document.body.appendChild(webview); | 619 document.body.appendChild(webview); |
612 } | 620 } |
613 | 621 |
614 // This test registers two listeners on an event (loadcommit) and removes | 622 // This test registers two listeners on an event (loadcommit) and removes |
615 // the <webview> tag when the first listener fires. | 623 // the <webview> tag when the first listener fires. |
616 // Current expected behavior is that the second event listener will still | 624 // Current expected behavior is that the second event listener will still |
617 // fire without crashing. | 625 // fire without crashing. |
618 function testDestroyOnEventListener() { | 626 function testDestroyOnEventListener() { |
619 var webview = util.createWebViewTagInDOM(arguments.callee.name); | 627 var webview = document.createElement('webview'); |
620 var url = 'data:text/html,<body>Destroy test</body>'; | 628 var url = 'data:text/html,<body>Destroy test</body>'; |
621 | 629 |
622 var loadCommitCount = 0; | 630 var loadCommitCount = 0; |
623 function loadCommitCommon(e) { | 631 function loadCommitCommon(e) { |
624 embedder.test.assertEq('loadcommit', e.type); | 632 embedder.test.assertEq('loadcommit', e.type); |
625 if (url != e.url) | 633 if (url != e.url) |
626 return; | 634 return; |
627 ++loadCommitCount; | 635 ++loadCommitCount; |
628 if (loadCommitCount == 2) { | 636 if (loadCommitCount == 2) { |
629 // Pass in a timeout so that we can catch if any additional loadcommit | 637 // Pass in a timeout so that we can catch if any additional loadcommit |
(...skipping 10 matching lines...) Expand all Loading... |
640 webview.addEventListener('loadcommit', function(e) { | 648 webview.addEventListener('loadcommit', function(e) { |
641 window.console.log('loadcommit1'); | 649 window.console.log('loadcommit1'); |
642 webview.parentNode.removeChild(webview); | 650 webview.parentNode.removeChild(webview); |
643 loadCommitCommon(e); | 651 loadCommitCommon(e); |
644 }); | 652 }); |
645 webview.addEventListener('loadcommit', function(e) { | 653 webview.addEventListener('loadcommit', function(e) { |
646 window.console.log('loadcommit2'); | 654 window.console.log('loadcommit2'); |
647 loadCommitCommon(e); | 655 loadCommitCommon(e); |
648 }); | 656 }); |
649 webview.setAttribute('src', url); | 657 webview.setAttribute('src', url); |
| 658 document.body.appendChild(webview); |
650 } | 659 } |
651 | 660 |
652 // This test registers two event listeners on a same event (loadcommit). | 661 // This test registers two event listeners on a same event (loadcommit). |
653 // Each of the listener tries to change some properties on the event param, | 662 // Each of the listener tries to change some properties on the event param, |
654 // which should not be possible. | 663 // which should not be possible. |
655 function testCannotMutateEventName() { | 664 function testCannotMutateEventName() { |
656 var webview = util.createWebViewTagInDOM(arguments.callee.name); | 665 var webview = document.createElement('webview'); |
657 var url = 'data:text/html,<body>Two</body>'; | 666 var url = 'data:text/html,<body>Two</body>'; |
658 | 667 |
659 var loadCommitACalled = false; | 668 var loadCommitACalled = false; |
660 var loadCommitBCalled = false; | 669 var loadCommitBCalled = false; |
661 | 670 |
662 var maybeFinishTest = function(e) { | 671 var maybeFinishTest = function(e) { |
663 if (loadCommitACalled && loadCommitBCalled) { | 672 if (loadCommitACalled && loadCommitBCalled) { |
664 embedder.test.assertEq('loadcommit', e.type); | 673 embedder.test.assertEq('loadcommit', e.type); |
665 embedder.test.succeed(); | 674 embedder.test.succeed(); |
666 } | 675 } |
(...skipping 21 matching lines...) Expand all Loading... |
688 maybeFinishTest(e); | 697 maybeFinishTest(e); |
689 } | 698 } |
690 }; | 699 }; |
691 | 700 |
692 // The test starts from here, by setting the src to |url|. Event | 701 // The test starts from here, by setting the src to |url|. Event |
693 // listener registration works because we already have a (dummy) src set | 702 // listener registration works because we already have a (dummy) src set |
694 // on the <webview> tag. | 703 // on the <webview> tag. |
695 webview.addEventListener('loadcommit', onLoadCommitA); | 704 webview.addEventListener('loadcommit', onLoadCommitA); |
696 webview.addEventListener('loadcommit', onLoadCommitB); | 705 webview.addEventListener('loadcommit', onLoadCommitB); |
697 webview.setAttribute('src', url); | 706 webview.setAttribute('src', url); |
| 707 document.body.appendChild(webview); |
698 } | 708 } |
699 | 709 |
700 // This test verifies that setting the partition attribute after the src has | 710 // This test verifies that the partion attribute cannot be changed after the src |
701 // been set raises an exception. | 711 // has been set. |
702 function testPartitionRaisesException() { | 712 function testPartitionChangeAfterNavigation() { |
703 var webview = document.createElement('webview'); | 713 var webview = document.createElement('webview'); |
704 var partitionAttribute = arguments.callee.name; | 714 var partitionAttribute = arguments.callee.name; |
705 webview.setAttribute('partition', partitionAttribute); | 715 webview.setAttribute('partition', partitionAttribute); |
706 | 716 |
707 var loadstopHandler = function(e) { | 717 var loadstopHandler = function(e) { |
708 try { | 718 webview.partition = 'illegal'; |
709 webview.partition = 'illegal'; | 719 embedder.test.assertEq(partitionAttribute, webview.partition); |
710 embedder.test.fail(); | 720 embedder.test.succeed(); |
711 } catch (e) { | |
712 embedder.test.assertEq(partitionAttribute, webview.partition); | |
713 embedder.test.succeed(); | |
714 } | |
715 }; | 721 }; |
716 webview.addEventListener('loadstop', loadstopHandler); | 722 webview.addEventListener('loadstop', loadstopHandler); |
717 | 723 |
718 document.body.appendChild(webview); | 724 document.body.appendChild(webview); |
719 webview.setAttribute('src', 'data:text/html,trigger navigation'); | 725 webview.setAttribute('src', 'data:text/html,trigger navigation'); |
720 } | 726 } |
721 | 727 |
722 // This test verifies that removing partition attribute after navigation does | 728 // This test verifies that removing partition attribute after navigation does |
723 // not work, i.e. the partition remains the same. | 729 // not work, i.e. the partition remains the same. |
724 function testPartitionRemovalAfterNavigationFails() { | 730 function testPartitionRemovalAfterNavigationFails() { |
(...skipping 1267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1992 'testDisplayNoneWebviewRemoveChild': testDisplayNoneWebviewRemoveChild, | 1998 'testDisplayNoneWebviewRemoveChild': testDisplayNoneWebviewRemoveChild, |
1993 'testInlineScriptFromAccessibleResources': | 1999 'testInlineScriptFromAccessibleResources': |
1994 testInlineScriptFromAccessibleResources, | 2000 testInlineScriptFromAccessibleResources, |
1995 'testInvalidChromeExtensionURL': testInvalidChromeExtensionURL, | 2001 'testInvalidChromeExtensionURL': testInvalidChromeExtensionURL, |
1996 'testWebRequestAPIExistence': testWebRequestAPIExistence, | 2002 'testWebRequestAPIExistence': testWebRequestAPIExistence, |
1997 'testEventName': testEventName, | 2003 'testEventName': testEventName, |
1998 'testOnEventProperties': testOnEventProperties, | 2004 'testOnEventProperties': testOnEventProperties, |
1999 'testLoadProgressEvent': testLoadProgressEvent, | 2005 'testLoadProgressEvent': testLoadProgressEvent, |
2000 'testDestroyOnEventListener': testDestroyOnEventListener, | 2006 'testDestroyOnEventListener': testDestroyOnEventListener, |
2001 'testCannotMutateEventName': testCannotMutateEventName, | 2007 'testCannotMutateEventName': testCannotMutateEventName, |
2002 'testPartitionRaisesException': testPartitionRaisesException, | 2008 'testPartitionChangeAfterNavigation': testPartitionChangeAfterNavigation, |
2003 'testPartitionRemovalAfterNavigationFails': | 2009 'testPartitionRemovalAfterNavigationFails': |
2004 testPartitionRemovalAfterNavigationFails, | 2010 testPartitionRemovalAfterNavigationFails, |
2005 'testExecuteScriptFail': testExecuteScriptFail, | 2011 'testExecuteScriptFail': testExecuteScriptFail, |
2006 'testExecuteScript': testExecuteScript, | 2012 'testExecuteScript': testExecuteScript, |
2007 'testExecuteScriptIsAbortedWhenWebViewSourceIsChanged': | 2013 'testExecuteScriptIsAbortedWhenWebViewSourceIsChanged': |
2008 testExecuteScriptIsAbortedWhenWebViewSourceIsChanged, | 2014 testExecuteScriptIsAbortedWhenWebViewSourceIsChanged, |
2009 'testTerminateAfterExit': testTerminateAfterExit, | 2015 'testTerminateAfterExit': testTerminateAfterExit, |
2010 'testAssignSrcAfterCrash': testAssignSrcAfterCrash, | 2016 'testAssignSrcAfterCrash': testAssignSrcAfterCrash, |
2011 'testNavOnConsecutiveSrcAttributeChanges': | 2017 'testNavOnConsecutiveSrcAttributeChanges': |
2012 testNavOnConsecutiveSrcAttributeChanges, | 2018 testNavOnConsecutiveSrcAttributeChanges, |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2054 'testFindAPI_findupdate': testFindAPI, | 2060 'testFindAPI_findupdate': testFindAPI, |
2055 'testLoadDataAPI': testLoadDataAPI | 2061 'testLoadDataAPI': testLoadDataAPI |
2056 }; | 2062 }; |
2057 | 2063 |
2058 onload = function() { | 2064 onload = function() { |
2059 chrome.test.getConfig(function(config) { | 2065 chrome.test.getConfig(function(config) { |
2060 embedder.setUp_(config); | 2066 embedder.setUp_(config); |
2061 chrome.test.sendMessage("Launched"); | 2067 chrome.test.sendMessage("Launched"); |
2062 }); | 2068 }); |
2063 }; | 2069 }; |
OLD | NEW |