OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 embedder = {}; | 5 var embedder = {}; |
6 | 6 |
7 // TODO(lfg) Move these functions to a common js. | 7 // TODO(lfg) Move these functions to a common js. |
8 embedder.setUp_ = function(config) { | 8 embedder.setUp_ = function(config) { |
9 if (!config || !config.testServer) { | 9 if (!config || !config.testServer) { |
10 return; | 10 return; |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 | 158 |
159 // Makes sure 'sizechanged' event is fired only if autosize attribute is | 159 // Makes sure 'sizechanged' event is fired only if autosize attribute is |
160 // specified. | 160 // specified. |
161 // After loading <webview> without autosize attribute and a size, say size1, | 161 // After loading <webview> without autosize attribute and a size, say size1, |
162 // we set autosize attribute and new min size with size2. We would get (only | 162 // we set autosize attribute and new min size with size2. We would get (only |
163 // one) sizechanged event with size1 as old size and size2 as new size. | 163 // one) sizechanged event with size1 as old size and size2 as new size. |
164 function testAutosizeAfterNavigation() { | 164 function testAutosizeAfterNavigation() { |
165 var webview = document.createElement('webview'); | 165 var webview = document.createElement('webview'); |
166 | 166 |
167 var step = 1; | 167 var step = 1; |
168 var autosizeWidth = -1; | |
169 var autosizeHeight = -1; | |
170 var sizeChangeHandler = function(e) { | 168 var sizeChangeHandler = function(e) { |
171 switch (step) { | 169 switch (step) { |
172 case 1: | 170 case 1: |
173 // This would be triggered after we set autosize attribute. | 171 // This would be triggered after we set autosize attribute. |
174 embedder.test.assertEq(50, e.oldWidth); | 172 embedder.test.assertEq(50, e.oldWidth); |
175 embedder.test.assertEq(100, e.oldHeight); | 173 embedder.test.assertEq(100, e.oldHeight); |
176 embedder.test.assertTrue(e.newWidth >= 60 && e.newWidth <= 70); | 174 embedder.test.assertTrue(e.newWidth >= 60 && e.newWidth <= 70); |
177 embedder.test.assertTrue(e.newHeight >= 110 && e.newHeight <= 120); | 175 embedder.test.assertTrue(e.newHeight >= 110 && e.newHeight <= 120); |
178 | 176 |
179 // Remove autosize attribute and expect webview to retain the same size. | 177 // Remove autosize attribute and expect webview to return to its |
180 autosizeWidth = e.newWidth; | 178 // original size. |
181 autosizeHeight = e.newHeight; | |
182 webview.removeAttribute('autosize'); | 179 webview.removeAttribute('autosize'); |
183 break; | 180 break; |
184 case 2: | 181 case 2: |
185 // Expect the autosized size. | 182 // Expect 50x100. |
186 embedder.test.assertEq(autosizeWidth, e.newWidth); | 183 embedder.test.assertEq(50, e.newWidth); |
187 embedder.test.assertEq(autosizeHeight, e.newHeight); | 184 embedder.test.assertEq(100, e.newHeight); |
188 | 185 |
189 embedder.test.succeed(); | 186 embedder.test.succeed(); |
190 break; | 187 break; |
191 default: | 188 default: |
192 window.console.log('Unexpected sizechanged event, step = ' + step); | 189 window.console.log('Unexpected sizechanged event, step = ' + step); |
193 embedder.test.fail(); | 190 embedder.test.fail(); |
194 break; | 191 break; |
195 } | 192 } |
196 | 193 |
197 ++step; | 194 ++step; |
(...skipping 1531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1729 'testWebRequestAPIExistence': testWebRequestAPIExistence, | 1726 'testWebRequestAPIExistence': testWebRequestAPIExistence, |
1730 'testWebRequestAPIGoogleProperty': testWebRequestAPIGoogleProperty | 1727 'testWebRequestAPIGoogleProperty': testWebRequestAPIGoogleProperty |
1731 }; | 1728 }; |
1732 | 1729 |
1733 onload = function() { | 1730 onload = function() { |
1734 chrome.test.getConfig(function(config) { | 1731 chrome.test.getConfig(function(config) { |
1735 embedder.setUp_(config); | 1732 embedder.setUp_(config); |
1736 chrome.test.sendMessage('LAUNCHED'); | 1733 chrome.test.sendMessage('LAUNCHED'); |
1737 }); | 1734 }); |
1738 }; | 1735 }; |
OLD | NEW |