Upstream version 5.34.98.0
[platform/framework/web/crosswalk.git] / src / chrome / test / data / extensions / platform_apps / web_view / size / main.js
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 function testSize() {
6   var webview = document.querySelector('webview');
7   // Since we can't currently inspect the page loaded inside the <webview>,
8   // the only way we can check that the shim is working is by changing the
9   // size and seeing if the shim updates the size of the DOM.
10   chrome.test.assertEq(300, webview.offsetWidth);
11   chrome.test.assertEq(200, webview.offsetHeight);
12
13   webview.style.width = '310px';
14   webview.style.height = '210px';
15
16   chrome.test.assertEq(310, webview.offsetWidth);
17   chrome.test.assertEq(210, webview.offsetHeight);
18
19   webview.style.width = '320px';
20   webview.style.height = '220px';
21
22   chrome.test.assertEq(320, webview.offsetWidth);
23   chrome.test.assertEq(220, webview.offsetHeight);
24
25   var dynamicWebViewTag = document.createElement('webview');
26   dynamicWebViewTag.setAttribute('src', 'data:text/html,dynamic browser');
27   dynamicWebViewTag.style.width = '330px';
28   dynamicWebViewTag.style.height = '230px';
29   document.body.appendChild(dynamicWebViewTag);
30
31   // Timeout is necessary to give the mutation observers a chance to fire.
32   setTimeout(function() {
33     chrome.test.assertEq(330, dynamicWebViewTag.offsetWidth);
34     chrome.test.assertEq(230, dynamicWebViewTag.offsetHeight);
35
36     chrome.test.succeed();
37   }, 0);
38 }
39
40 onload = function() {
41   chrome.test.runTests([testSize]);
42 };