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 window.console.log('The resize test has been injected into webview.'); | |
lazyboy
2014/10/03 20:30:05
if (!results || !results.length) embedder.test.fai
Fady Samuel
2014/10/03 21:52:30
Done.
| |
1589 } | |
1590 ); | |
1591 webview.executeScript( | |
1592 {file: 'inject_comm_channel.js'}, | |
1593 function(results) { | |
1594 window.console.log('The guest script for a two-way comm channel has ' + | |
lazyboy
2014/10/03 20:30:05
Same here.
Fady Samuel
2014/10/03 21:52:30
Done.
| |
1595 'been injected into webview.'); | |
1596 // Establish a communication channel with the guest. | |
1597 var msg = ['connect']; | |
1598 webview.contentWindow.postMessage(JSON.stringify(msg), '*'); | |
1599 } | |
1600 ); | |
1601 }); | |
1602 window.addEventListener('message', function(e) { | |
1603 var data = JSON.parse(e.data); | |
1604 if (data[0] == 'connected') { | |
1605 console.log('A communication channel has been established with webview.'); | |
1606 console.log('Resizing <webview> width from 300px to 400px.'); | |
1607 webview.style.display = 'none'; | |
1608 window.setTimeout(function() { | |
1609 webview.style.width = '400px'; | |
lazyboy
2014/10/03 20:30:05
From what i've seen this probably is race-y, you'r
Fady Samuel
2014/10/03 21:52:30
I don't know the full flow of code so I'm not 100%
| |
1610 window.setTimeout(function() { | |
1611 webview.style.display = 'block'; | |
1612 }, 0); | |
1613 }, 0); | |
1614 return; | |
1615 } | |
1616 if (data[0] == 'resize') { | |
1617 var width = data[1]; | |
1618 var height = data[2]; | |
1619 embedder.test.assertEq(400, width); | |
1620 embedder.test.assertEq(300, height); | |
1621 embedder.test.succeed(); | |
1622 return; | |
1623 } | |
1624 window.console.log('Unexpected message: \'' + data[0] + '\''); | |
1625 embedder.test.fail(); | |
1626 }); | |
1627 document.body.appendChild(webview); | |
1628 } | |
1629 | |
1574 function testPostMessageCommChannel() { | 1630 function testPostMessageCommChannel() { |
1575 var webview = new WebView(); | 1631 var webview = new WebView(); |
1576 webview.src = 'about:blank'; | 1632 webview.src = 'about:blank'; |
1577 webview.addEventListener('loadstop', function(e) { | 1633 webview.addEventListener('loadstop', function(e) { |
1578 webview.executeScript( | 1634 webview.executeScript( |
1579 {file: 'inject_comm_channel.js'}, | 1635 {file: 'inject_comm_channel.js'}, |
1580 function(results) { | 1636 function(results) { |
1581 window.console.log('The guest script for a two-way comm channel has ' + | 1637 window.console.log('The guest script for a two-way comm channel has ' + |
1582 'been injected into webview.'); | 1638 'been injected into webview.'); |
1583 // Establish a communication channel with the guest. | 1639 // Establish a communication channel with the guest. |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1926 'testLoadAbortIllegalJavaScriptURL': testLoadAbortIllegalJavaScriptURL, | 1982 'testLoadAbortIllegalJavaScriptURL': testLoadAbortIllegalJavaScriptURL, |
1927 'testLoadAbortInvalidNavigation': testLoadAbortInvalidNavigation, | 1983 'testLoadAbortInvalidNavigation': testLoadAbortInvalidNavigation, |
1928 'testLoadAbortNonWebSafeScheme': testLoadAbortNonWebSafeScheme, | 1984 'testLoadAbortNonWebSafeScheme': testLoadAbortNonWebSafeScheme, |
1929 'testNavigateAfterResize': testNavigateAfterResize, | 1985 'testNavigateAfterResize': testNavigateAfterResize, |
1930 'testNavigationToExternalProtocol': testNavigationToExternalProtocol, | 1986 'testNavigationToExternalProtocol': testNavigationToExternalProtocol, |
1931 'testReload': testReload, | 1987 'testReload': testReload, |
1932 'testReloadAfterTerminate': testReloadAfterTerminate, | 1988 'testReloadAfterTerminate': testReloadAfterTerminate, |
1933 'testRemoveWebviewOnExit': testRemoveWebviewOnExit, | 1989 'testRemoveWebviewOnExit': testRemoveWebviewOnExit, |
1934 'testRemoveWebviewAfterNavigation': testRemoveWebviewAfterNavigation, | 1990 'testRemoveWebviewAfterNavigation': testRemoveWebviewAfterNavigation, |
1935 'testResizeWebviewResizesContent': testResizeWebviewResizesContent, | 1991 'testResizeWebviewResizesContent': testResizeWebviewResizesContent, |
1992 'testResizeWebviewWithDisplayNoneResizesContent': | |
1993 testResizeWebviewWithDisplayNoneResizesContent, | |
1936 'testPostMessageCommChannel': testPostMessageCommChannel, | 1994 'testPostMessageCommChannel': testPostMessageCommChannel, |
1937 'testScreenshotCapture' : testScreenshotCapture, | 1995 'testScreenshotCapture' : testScreenshotCapture, |
1938 'testZoomAPI' : testZoomAPI, | 1996 'testZoomAPI' : testZoomAPI, |
1939 'testFindAPI': testFindAPI, | 1997 'testFindAPI': testFindAPI, |
1940 'testFindAPI_findupdate': testFindAPI, | 1998 'testFindAPI_findupdate': testFindAPI, |
1941 'testLoadDataAPI': testLoadDataAPI | 1999 'testLoadDataAPI': testLoadDataAPI |
1942 }; | 2000 }; |
1943 | 2001 |
1944 onload = function() { | 2002 onload = function() { |
1945 chrome.test.getConfig(function(config) { | 2003 chrome.test.getConfig(function(config) { |
1946 embedder.setUp_(config); | 2004 embedder.setUp_(config); |
1947 chrome.test.sendMessage("Launched"); | 2005 chrome.test.sendMessage("Launched"); |
1948 }); | 2006 }); |
1949 }; | 2007 }; |
OLD | NEW |