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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 function testAutosizeBeforeNavigation() { | 215 function testAutosizeBeforeNavigation() { |
216 var webview = document.createElement('webview'); | 216 var webview = document.createElement('webview'); |
217 | 217 |
218 webview.setAttribute('autosize', 'true'); | 218 webview.setAttribute('autosize', 'true'); |
219 webview.setAttribute('minwidth', 200); | 219 webview.setAttribute('minwidth', 200); |
220 webview.setAttribute('maxwidth', 210); | 220 webview.setAttribute('maxwidth', 210); |
221 webview.setAttribute('minheight', 100); | 221 webview.setAttribute('minheight', 100); |
222 webview.setAttribute('maxheight', 110); | 222 webview.setAttribute('maxheight', 110); |
223 | 223 |
224 webview.addEventListener('sizechanged', function(e) { | 224 webview.addEventListener('sizechanged', function(e) { |
225 embedder.test.assertEq(0, e.oldWidth); | |
226 embedder.test.assertEq(0, e.oldHeight); | |
227 embedder.test.assertTrue(e.newWidth >= 200 && e.newWidth <= 210); | 225 embedder.test.assertTrue(e.newWidth >= 200 && e.newWidth <= 210); |
228 embedder.test.assertTrue(e.newHeight >= 100 && e.newHeight <= 110); | 226 embedder.test.assertTrue(e.newHeight >= 100 && e.newHeight <= 110); |
229 embedder.test.succeed(); | 227 embedder.test.succeed(); |
230 }); | 228 }); |
231 | 229 |
232 webview.setAttribute('src', 'data:text/html,webview test sizechanged event'); | 230 webview.setAttribute('src', 'data:text/html,webview test sizechanged event'); |
233 document.body.appendChild(webview); | 231 document.body.appendChild(webview); |
234 } | 232 } |
235 | 233 |
236 // This test verifies that a lengthy page with autosize enabled will report | 234 // This test verifies that a lengthy page with autosize enabled will report |
237 // the correct height in the sizechanged event. | 235 // the correct height in the sizechanged event. |
238 function testAutosizeHeight() { | 236 function testAutosizeHeight() { |
239 var webview = document.createElement('webview'); | 237 var webview = document.createElement('webview'); |
240 | 238 |
241 webview.autosize = true; | 239 webview.autosize = true; |
242 webview.minwidth = 200; | 240 webview.minwidth = 200; |
243 webview.maxwidth = 210; | 241 webview.maxwidth = 210; |
244 webview.minheight = 40; | 242 webview.minheight = 40; |
245 webview.maxheight = 200; | 243 webview.maxheight = 200; |
246 | 244 |
247 var step = 1; | 245 var step = 1; |
248 webview.addEventListener('sizechanged', function(e) { | 246 webview.addEventListener('sizechanged', function(e) { |
249 switch (step) { | 247 switch (step) { |
250 case 1: | 248 case 1: |
251 embedder.test.assertEq(0, e.oldHeight); | |
252 embedder.test.assertEq(200, e.newHeight); | 249 embedder.test.assertEq(200, e.newHeight); |
253 // Change the maxheight to verify that we see the change. | 250 // Change the maxheight to verify that we see the change. |
254 webview.maxheight = 50; | 251 webview.maxheight = 50; |
255 break; | 252 break; |
256 case 2: | 253 case 2: |
257 embedder.test.assertEq(200, e.oldHeight); | 254 embedder.test.assertEq(200, e.oldHeight); |
258 embedder.test.assertEq(50, e.newHeight); | 255 embedder.test.assertEq(50, e.newHeight); |
259 embedder.test.succeed(); | 256 embedder.test.succeed(); |
260 break; | 257 break; |
261 default: | 258 default: |
(...skipping 1464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1726 'testWebRequestAPIExistence': testWebRequestAPIExistence, | 1723 'testWebRequestAPIExistence': testWebRequestAPIExistence, |
1727 'testWebRequestAPIGoogleProperty': testWebRequestAPIGoogleProperty | 1724 'testWebRequestAPIGoogleProperty': testWebRequestAPIGoogleProperty |
1728 }; | 1725 }; |
1729 | 1726 |
1730 onload = function() { | 1727 onload = function() { |
1731 chrome.test.getConfig(function(config) { | 1728 chrome.test.getConfig(function(config) { |
1732 embedder.setUp_(config); | 1729 embedder.setUp_(config); |
1733 chrome.test.sendMessage('LAUNCHED'); | 1730 chrome.test.sendMessage('LAUNCHED'); |
1734 }); | 1731 }); |
1735 }; | 1732 }; |
OLD | NEW |