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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 | 86 |
87 embedder.test.assertFalse = function(condition) { | 87 embedder.test.assertFalse = function(condition) { |
88 if (condition) { | 88 if (condition) { |
89 console.log('assertion failed: false != ' + condition); | 89 console.log('assertion failed: false != ' + condition); |
90 embedder.test.fail(); | 90 embedder.test.fail(); |
91 } | 91 } |
92 }; | 92 }; |
93 | 93 |
94 // Tests begin. | 94 // Tests begin. |
95 | 95 |
| 96 // This test verifies that a lengthy page with autosize enabled will report |
| 97 // the correct height in the sizechanged event. |
| 98 function testAutosizeHeight() { |
| 99 var webview = document.createElement('webview'); |
| 100 |
| 101 webview.autosize = true; |
| 102 webview.minwidth = 200; |
| 103 webview.maxwidth = 210; |
| 104 webview.minheight = 40; |
| 105 webview.maxheight = 200; |
| 106 |
| 107 var step = 1; |
| 108 webview.addEventListener('sizechanged', function(e) { |
| 109 switch (step) { |
| 110 case 1: |
| 111 embedder.test.assertEq(0, e.oldHeight); |
| 112 embedder.test.assertEq(200, e.newHeight); |
| 113 // Change the maxheight to verify that we see the change. |
| 114 webview.maxheight = 50; |
| 115 break; |
| 116 case 2: |
| 117 embedder.test.assertEq(200, e.oldHeight); |
| 118 embedder.test.assertEq(50, e.newHeight); |
| 119 embedder.test.succeed(); |
| 120 break; |
| 121 default: |
| 122 window.console.log('Unexpected sizechanged event, step = ' + step); |
| 123 embedder.test.fail(); |
| 124 break; |
| 125 } |
| 126 ++step; |
| 127 }); |
| 128 |
| 129 webview.src = 'data:text/html,' + |
| 130 'a<br/>b<br/>c<br/>d<br/>e<br/>f<br/>' + |
| 131 'a<br/>b<br/>c<br/>d<br/>e<br/>f<br/>' + |
| 132 'a<br/>b<br/>c<br/>d<br/>e<br/>f<br/>' + |
| 133 'a<br/>b<br/>c<br/>d<br/>e<br/>f<br/>' + |
| 134 'a<br/>b<br/>c<br/>d<br/>e<br/>f<br/>'; |
| 135 document.body.appendChild(webview); |
| 136 } |
| 137 |
96 // This test verifies that if a browser plugin is in autosize mode before | 138 // This test verifies that if a browser plugin is in autosize mode before |
97 // navigation then the guest starts auto-sized. | 139 // navigation then the guest starts auto-sized. |
98 function testAutosizeBeforeNavigation() { | 140 function testAutosizeBeforeNavigation() { |
99 var webview = document.createElement('webview'); | 141 var webview = document.createElement('webview'); |
100 | 142 |
101 webview.setAttribute('autosize', 'true'); | 143 webview.setAttribute('autosize', 'true'); |
102 webview.setAttribute('minwidth', 200); | 144 webview.setAttribute('minwidth', 200); |
103 webview.setAttribute('maxwidth', 210); | 145 webview.setAttribute('maxwidth', 210); |
104 webview.setAttribute('minheight', 100); | 146 webview.setAttribute('minheight', 100); |
105 webview.setAttribute('maxheight', 110); | 147 webview.setAttribute('maxheight', 110); |
(...skipping 1619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1725 }); | 1767 }); |
1726 wv.find("dog"); | 1768 wv.find("dog"); |
1727 wv.find("cat"); | 1769 wv.find("cat"); |
1728 wv.find("dog"); | 1770 wv.find("dog"); |
1729 }); | 1771 }); |
1730 | 1772 |
1731 document.body.appendChild(webview); | 1773 document.body.appendChild(webview); |
1732 }; | 1774 }; |
1733 | 1775 |
1734 embedder.test.testList = { | 1776 embedder.test.testList = { |
| 1777 'testAutosizeHeight': testAutosizeHeight, |
1735 'testAutosizeAfterNavigation': testAutosizeAfterNavigation, | 1778 'testAutosizeAfterNavigation': testAutosizeAfterNavigation, |
1736 'testAutosizeBeforeNavigation': testAutosizeBeforeNavigation, | 1779 'testAutosizeBeforeNavigation': testAutosizeBeforeNavigation, |
1737 'testAutosizeRemoveAttributes': testAutosizeRemoveAttributes, | 1780 'testAutosizeRemoveAttributes': testAutosizeRemoveAttributes, |
1738 'testAutosizeWithPartialAttributes': testAutosizeWithPartialAttributes, | 1781 'testAutosizeWithPartialAttributes': testAutosizeWithPartialAttributes, |
1739 'testAPIMethodExistence': testAPIMethodExistence, | 1782 'testAPIMethodExistence': testAPIMethodExistence, |
1740 'testChromeExtensionURL': testChromeExtensionURL, | 1783 'testChromeExtensionURL': testChromeExtensionURL, |
1741 'testChromeExtensionRelativePath': testChromeExtensionRelativePath, | 1784 'testChromeExtensionRelativePath': testChromeExtensionRelativePath, |
1742 'testDisplayNoneWebviewLoad': testDisplayNoneWebviewLoad, | 1785 'testDisplayNoneWebviewLoad': testDisplayNoneWebviewLoad, |
1743 'testDisplayNoneWebviewRemoveChild': testDisplayNoneWebviewRemoveChild, | 1786 'testDisplayNoneWebviewRemoveChild': testDisplayNoneWebviewRemoveChild, |
1744 'testInlineScriptFromAccessibleResources': | 1787 'testInlineScriptFromAccessibleResources': |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1800 'testFindAPI': testFindAPI, | 1843 'testFindAPI': testFindAPI, |
1801 'testFindAPI_findupdate': testFindAPI | 1844 'testFindAPI_findupdate': testFindAPI |
1802 }; | 1845 }; |
1803 | 1846 |
1804 onload = function() { | 1847 onload = function() { |
1805 chrome.test.getConfig(function(config) { | 1848 chrome.test.getConfig(function(config) { |
1806 embedder.setUp_(config); | 1849 embedder.setUp_(config); |
1807 chrome.test.sendMessage("Launched"); | 1850 chrome.test.sendMessage("Launched"); |
1808 }); | 1851 }); |
1809 }; | 1852 }; |
OLD | NEW |