| 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; |
| 168 var sizeChangeHandler = function(e) { | 170 var sizeChangeHandler = function(e) { |
| 169 switch (step) { | 171 switch (step) { |
| 170 case 1: | 172 case 1: |
| 171 // This would be triggered after we set autosize attribute. | 173 // This would be triggered after we set autosize attribute. |
| 172 embedder.test.assertEq(50, e.oldWidth); | 174 embedder.test.assertEq(50, e.oldWidth); |
| 173 embedder.test.assertEq(100, e.oldHeight); | 175 embedder.test.assertEq(100, e.oldHeight); |
| 174 embedder.test.assertTrue(e.newWidth >= 60 && e.newWidth <= 70); | 176 embedder.test.assertTrue(e.newWidth >= 60 && e.newWidth <= 70); |
| 175 embedder.test.assertTrue(e.newHeight >= 110 && e.newHeight <= 120); | 177 embedder.test.assertTrue(e.newHeight >= 110 && e.newHeight <= 120); |
| 176 | 178 |
| 177 // Remove autosize attribute and expect webview to return to its | 179 // Remove autosize attribute and expect webview to retain the same size. |
| 178 // original size. | 180 autosizeWidth = e.newWidth; |
| 181 autosizeHeight = e.newHeight; |
| 179 webview.removeAttribute('autosize'); | 182 webview.removeAttribute('autosize'); |
| 180 break; | 183 break; |
| 181 case 2: | 184 case 2: |
| 182 // Expect 50x100. | 185 // Expect the autosized size. |
| 183 embedder.test.assertEq(50, e.newWidth); | 186 embedder.test.assertEq(autosizeWidth, e.newWidth); |
| 184 embedder.test.assertEq(100, e.newHeight); | 187 embedder.test.assertEq(autosizeHeight, e.newHeight); |
| 185 | 188 |
| 186 embedder.test.succeed(); | 189 embedder.test.succeed(); |
| 187 break; | 190 break; |
| 188 default: | 191 default: |
| 189 window.console.log('Unexpected sizechanged event, step = ' + step); | 192 window.console.log('Unexpected sizechanged event, step = ' + step); |
| 190 embedder.test.fail(); | 193 embedder.test.fail(); |
| 191 break; | 194 break; |
| 192 } | 195 } |
| 193 | 196 |
| 194 ++step; | 197 ++step; |
| (...skipping 1538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1733 'testWebRequestAPIExistence': testWebRequestAPIExistence, | 1736 'testWebRequestAPIExistence': testWebRequestAPIExistence, |
| 1734 'testWebRequestAPIGoogleProperty': testWebRequestAPIGoogleProperty | 1737 'testWebRequestAPIGoogleProperty': testWebRequestAPIGoogleProperty |
| 1735 }; | 1738 }; |
| 1736 | 1739 |
| 1737 onload = function() { | 1740 onload = function() { |
| 1738 chrome.test.getConfig(function(config) { | 1741 chrome.test.getConfig(function(config) { |
| 1739 embedder.setUp_(config); | 1742 embedder.setUp_(config); |
| 1740 chrome.test.sendMessage('LAUNCHED'); | 1743 chrome.test.sendMessage('LAUNCHED'); |
| 1741 }); | 1744 }); |
| 1742 }; | 1745 }; |
| OLD | NEW |