OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 util = {}; | 5 var util = {}; |
6 var embedder = {}; | 6 var embedder = {}; |
7 embedder.baseGuestURL = ''; | 7 embedder.baseGuestURL = ''; |
8 embedder.emptyGuestURL = ''; | 8 embedder.emptyGuestURL = ''; |
9 embedder.windowOpenGuestURL = ''; | 9 embedder.windowOpenGuestURL = ''; |
10 embedder.noReferrerGuestURL = ''; | 10 embedder.noReferrerGuestURL = ''; |
(...skipping 1553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1564 embedder.test.assertEq(300, height); | 1564 embedder.test.assertEq(300, height); |
1565 embedder.test.succeed(); | 1565 embedder.test.succeed(); |
1566 return; | 1566 return; |
1567 } | 1567 } |
1568 console.log('Unexpected message: \'' + data[0] + '\''); | 1568 console.log('Unexpected message: \'' + data[0] + '\''); |
1569 embedder.test.fail(); | 1569 embedder.test.fail(); |
1570 }); | 1570 }); |
1571 document.body.appendChild(webview); | 1571 document.body.appendChild(webview); |
1572 } | 1572 } |
1573 | 1573 |
| 1574 function testResizeWebviewWithDisplayNoneResizesContent() { |
| 1575 var webview = new WebView(); |
| 1576 webview.src = 'about:blank'; |
| 1577 var loadStopCalled = false; |
| 1578 webview.addEventListener('loadstop', function listener(e) { |
| 1579 if (loadStopCalled) { |
| 1580 window.console.log('webview is unexpectedly reloading.'); |
| 1581 embedder.test.fail(); |
| 1582 return; |
| 1583 } |
| 1584 loadStopCalled = true; |
| 1585 webview.executeScript( |
| 1586 {file: 'inject_resize_test.js'}, |
| 1587 function(results) { |
| 1588 if (!results || !results.length) { |
| 1589 embedder.test.fail(); |
| 1590 return; |
| 1591 } |
| 1592 window.console.log('The resize test has been injected into webview.'); |
| 1593 } |
| 1594 ); |
| 1595 webview.executeScript( |
| 1596 {file: 'inject_comm_channel.js'}, |
| 1597 function(results) { |
| 1598 if (!results || !results.length) { |
| 1599 embedder.test.fail(); |
| 1600 return; |
| 1601 } |
| 1602 window.console.log('The guest script for a two-way comm channel has ' + |
| 1603 'been injected into webview.'); |
| 1604 // Establish a communication channel with the guest. |
| 1605 var msg = ['connect']; |
| 1606 webview.contentWindow.postMessage(JSON.stringify(msg), '*'); |
| 1607 } |
| 1608 ); |
| 1609 }); |
| 1610 window.addEventListener('message', function(e) { |
| 1611 var data = JSON.parse(e.data); |
| 1612 if (data[0] == 'connected') { |
| 1613 console.log('A communication channel has been established with webview.'); |
| 1614 console.log('Resizing <webview> width from 300px to 400px.'); |
| 1615 webview.style.display = 'none'; |
| 1616 window.setTimeout(function() { |
| 1617 webview.style.width = '400px'; |
| 1618 window.setTimeout(function() { |
| 1619 webview.style.display = 'block'; |
| 1620 }, 0); |
| 1621 }, 0); |
| 1622 return; |
| 1623 } |
| 1624 if (data[0] == 'resize') { |
| 1625 var width = data[1]; |
| 1626 var height = data[2]; |
| 1627 embedder.test.assertEq(400, width); |
| 1628 embedder.test.assertEq(300, height); |
| 1629 embedder.test.succeed(); |
| 1630 return; |
| 1631 } |
| 1632 window.console.log('Unexpected message: \'' + data[0] + '\''); |
| 1633 embedder.test.fail(); |
| 1634 }); |
| 1635 document.body.appendChild(webview); |
| 1636 } |
| 1637 |
1574 function testPostMessageCommChannel() { | 1638 function testPostMessageCommChannel() { |
1575 var webview = new WebView(); | 1639 var webview = new WebView(); |
1576 webview.src = 'about:blank'; | 1640 webview.src = 'about:blank'; |
1577 webview.addEventListener('loadstop', function(e) { | 1641 webview.addEventListener('loadstop', function(e) { |
1578 webview.executeScript( | 1642 webview.executeScript( |
1579 {file: 'inject_comm_channel.js'}, | 1643 {file: 'inject_comm_channel.js'}, |
1580 function(results) { | 1644 function(results) { |
1581 window.console.log('The guest script for a two-way comm channel has ' + | 1645 window.console.log('The guest script for a two-way comm channel has ' + |
1582 'been injected into webview.'); | 1646 'been injected into webview.'); |
1583 // Establish a communication channel with the guest. | 1647 // Establish a communication channel with the guest. |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1926 'testLoadAbortIllegalJavaScriptURL': testLoadAbortIllegalJavaScriptURL, | 1990 'testLoadAbortIllegalJavaScriptURL': testLoadAbortIllegalJavaScriptURL, |
1927 'testLoadAbortInvalidNavigation': testLoadAbortInvalidNavigation, | 1991 'testLoadAbortInvalidNavigation': testLoadAbortInvalidNavigation, |
1928 'testLoadAbortNonWebSafeScheme': testLoadAbortNonWebSafeScheme, | 1992 'testLoadAbortNonWebSafeScheme': testLoadAbortNonWebSafeScheme, |
1929 'testNavigateAfterResize': testNavigateAfterResize, | 1993 'testNavigateAfterResize': testNavigateAfterResize, |
1930 'testNavigationToExternalProtocol': testNavigationToExternalProtocol, | 1994 'testNavigationToExternalProtocol': testNavigationToExternalProtocol, |
1931 'testReload': testReload, | 1995 'testReload': testReload, |
1932 'testReloadAfterTerminate': testReloadAfterTerminate, | 1996 'testReloadAfterTerminate': testReloadAfterTerminate, |
1933 'testRemoveWebviewOnExit': testRemoveWebviewOnExit, | 1997 'testRemoveWebviewOnExit': testRemoveWebviewOnExit, |
1934 'testRemoveWebviewAfterNavigation': testRemoveWebviewAfterNavigation, | 1998 'testRemoveWebviewAfterNavigation': testRemoveWebviewAfterNavigation, |
1935 'testResizeWebviewResizesContent': testResizeWebviewResizesContent, | 1999 'testResizeWebviewResizesContent': testResizeWebviewResizesContent, |
| 2000 'testResizeWebviewWithDisplayNoneResizesContent': |
| 2001 testResizeWebviewWithDisplayNoneResizesContent, |
1936 'testPostMessageCommChannel': testPostMessageCommChannel, | 2002 'testPostMessageCommChannel': testPostMessageCommChannel, |
1937 'testScreenshotCapture' : testScreenshotCapture, | 2003 'testScreenshotCapture' : testScreenshotCapture, |
1938 'testZoomAPI' : testZoomAPI, | 2004 'testZoomAPI' : testZoomAPI, |
1939 'testFindAPI': testFindAPI, | 2005 'testFindAPI': testFindAPI, |
1940 'testFindAPI_findupdate': testFindAPI, | 2006 'testFindAPI_findupdate': testFindAPI, |
1941 'testLoadDataAPI': testLoadDataAPI | 2007 'testLoadDataAPI': testLoadDataAPI |
1942 }; | 2008 }; |
1943 | 2009 |
1944 onload = function() { | 2010 onload = function() { |
1945 chrome.test.getConfig(function(config) { | 2011 chrome.test.getConfig(function(config) { |
1946 embedder.setUp_(config); | 2012 embedder.setUp_(config); |
1947 chrome.test.sendMessage("Launched"); | 2013 chrome.test.sendMessage("Launched"); |
1948 }); | 2014 }); |
1949 }; | 2015 }; |
OLD | NEW |