Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(449)

Side by Side Diff: extensions/test/data/web_view/apitest/main.js

Issue 847893002: Implemented explicit resizing from guestview. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Another small fix. Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « extensions/renderer/resources/guest_view/web_view_attributes.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 1531 matching lines...) Expand 10 before | Expand all | Expand 10 after
1726 'testWebRequestAPIExistence': testWebRequestAPIExistence, 1729 'testWebRequestAPIExistence': testWebRequestAPIExistence,
1727 'testWebRequestAPIGoogleProperty': testWebRequestAPIGoogleProperty 1730 'testWebRequestAPIGoogleProperty': testWebRequestAPIGoogleProperty
1728 }; 1731 };
1729 1732
1730 onload = function() { 1733 onload = function() {
1731 chrome.test.getConfig(function(config) { 1734 chrome.test.getConfig(function(config) {
1732 embedder.setUp_(config); 1735 embedder.setUp_(config);
1733 chrome.test.sendMessage('LAUNCHED'); 1736 chrome.test.sendMessage('LAUNCHED');
1734 }); 1737 });
1735 }; 1738 };
OLDNEW
« no previous file with comments | « extensions/renderer/resources/guest_view/web_view_attributes.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698