Chromium Code Reviews| Index: chrome/test/data/extensions/platform_apps/web_view/autosize/main.js |
| diff --git a/chrome/test/data/extensions/platform_apps/web_view/autosize/main.js b/chrome/test/data/extensions/platform_apps/web_view/autosize/main.js |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..dbad0b7624b8520e1d54df7a4bbd405f9766ca6e |
| --- /dev/null |
| +++ b/chrome/test/data/extensions/platform_apps/web_view/autosize/main.js |
| @@ -0,0 +1,64 @@ |
| +// Copyright 2013 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +function testAutoSize() { |
| + var webview = document.querySelector('webview'); |
| + |
| + var minw = 1600; |
| + var maxw = 3000; |
| + var minh = 1600; |
| + var maxh = 3000; |
| + |
| + webview.addEventListener('loadstop', function(e) { |
| + window.console.log('guest.loadstop'); |
| + // Note that we set the autosize attribute first to check incorrect |
| + // damage buffer allocation. |
| + // |
| + // Consider a case where: |
| + // Initially, <webview>.width = 300 (default width). |
| + // Then we set |
| + // <webview>.autosize = true |
| + // And then we set |
| + // <webview>.minwidth = 200 |
| + // and |
| + // <webview>.maxwidth = 800 |
| + // If the autosize logic decided to set the width to 400 (something > 300), |
| + // then we won't have enough memory in damage buffer to render. |
|
Fady Samuel
2013/08/27 14:16:18
That doesn't make sense to me. We set the damage b
lazyboy
2013/08/27 23:22:17
See other comment.
|
| + // When tried manually, this would cause garbage to be rendered (around the |
| + // bottom portion of plugin). In test we set the value to high so increase |
| + // the chance of invalid memory access. |
| + webview.autosize = true; |
| + |
| + // Ask for a larger size so we can expose memory access bug. |
| + webview.maxwidth = maxw; |
| + webview.maxheight = maxh; |
| + webview.minwidth = minw; |
| + webview.minheight = minh; |
| + }); |
| + |
| + webview.addEventListener('sizechanged', function(e) { |
| + window.console.log('sizechagned: dimension: ' + e.newWidth + ' X ' + |
| + e.newHeight); |
| + chrome.test.assertTrue(e.newWidth >= minw); |
| + chrome.test.assertTrue(e.newWidth <= maxw); |
| + chrome.test.assertTrue(e.newHeight >= minh); |
| + chrome.test.assertTrue(e.newHeight <= maxh); |
| + |
| + chrome.test.succeed(); |
| + }); |
| + document.body.appendChild(webview); |
| + |
| + var longString = 'a b c d e f g h i j k l m o p q r s t u v w x y z'; |
| + for (var i = 0; i < 4; ++i) { |
| + longString += longString; |
| + } |
| + webview.setAttribute('src', |
| + 'data:text/html,<body bgcolor="red">' + |
| + '<div style="width: 400px; height: 200px;">' + longString + '</div>' + |
| + longString + '</body>'); |
| +} |
| + |
| +onload = function() { |
| + chrome.test.runTests([testAutoSize]); |
| +}; |