OLD | NEW |
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 1667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1678 function testWebRequestAPIGoogleProperty() { | 1678 function testWebRequestAPIGoogleProperty() { |
1679 var webview = new WebView(); | 1679 var webview = new WebView(); |
1680 webview.request.onBeforeRequest.addListener(function(e) { | 1680 webview.request.onBeforeRequest.addListener(function(e) { |
1681 embedder.test.succeed(); | 1681 embedder.test.succeed(); |
1682 return {cancel: true}; | 1682 return {cancel: true}; |
1683 }, { urls: ['<all_urls>']}, ['blocking']) ; | 1683 }, { urls: ['<all_urls>']}, ['blocking']) ; |
1684 webview.src = 'http://clients6.google.com'; | 1684 webview.src = 'http://clients6.google.com'; |
1685 document.body.appendChild(webview); | 1685 document.body.appendChild(webview); |
1686 } | 1686 } |
1687 | 1687 |
1688 // This is a basic test to verify that image data is returned by | |
1689 // captureVisibleRegion(). | |
1690 function testCaptureVisibleRegion() { | |
1691 var webview = document.createElement('webview'); | |
1692 webview.setAttribute('src', 'data:text/html,webview test'); | |
1693 | |
1694 webview.addEventListener('loadstop', function(e) { | |
1695 webview.captureVisibleRegion({}, function(imgdata) { | |
1696 if (chrome.runtime.lastError) { | |
1697 console.log('webview.apitest.testCaptureVisibleRegion: ' + | |
1698 chrome.runtime.lastError.message); | |
1699 embedder.test.fail(); | |
1700 } else { | |
1701 embedder.test.assertTrue( | |
1702 imgdata.indexOf('data:image/jpeg;base64') == 0); | |
1703 embedder.test.succeed(); | |
1704 } | |
1705 }); | |
1706 }); | |
1707 document.body.appendChild(webview); | |
1708 } | |
1709 | |
1710 // Tests end. | 1688 // Tests end. |
1711 | 1689 |
1712 embedder.test.testList = { | 1690 embedder.test.testList = { |
1713 'testAllowTransparencyAttribute': testAllowTransparencyAttribute, | 1691 'testAllowTransparencyAttribute': testAllowTransparencyAttribute, |
1714 'testAPIMethodExistence': testAPIMethodExistence, | 1692 'testAPIMethodExistence': testAPIMethodExistence, |
1715 'testAssignSrcAfterCrash': testAssignSrcAfterCrash, | 1693 'testAssignSrcAfterCrash': testAssignSrcAfterCrash, |
1716 'testAutosizeAfterNavigation': testAutosizeAfterNavigation, | 1694 'testAutosizeAfterNavigation': testAutosizeAfterNavigation, |
1717 'testAutosizeBeforeNavigation': testAutosizeBeforeNavigation, | 1695 'testAutosizeBeforeNavigation': testAutosizeBeforeNavigation, |
1718 'testAutosizeHeight': testAutosizeHeight, | 1696 'testAutosizeHeight': testAutosizeHeight, |
1719 'testAutosizeRemoveAttributes': testAutosizeRemoveAttributes, | 1697 'testAutosizeRemoveAttributes': testAutosizeRemoveAttributes, |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1767 'testReload': testReload, | 1745 'testReload': testReload, |
1768 'testReloadAfterTerminate': testReloadAfterTerminate, | 1746 'testReloadAfterTerminate': testReloadAfterTerminate, |
1769 'testRemoveSrcAttribute': testRemoveSrcAttribute, | 1747 'testRemoveSrcAttribute': testRemoveSrcAttribute, |
1770 'testRemoveWebviewAfterNavigation': testRemoveWebviewAfterNavigation, | 1748 'testRemoveWebviewAfterNavigation': testRemoveWebviewAfterNavigation, |
1771 'testRemoveWebviewOnExit': testRemoveWebviewOnExit, | 1749 'testRemoveWebviewOnExit': testRemoveWebviewOnExit, |
1772 'testResizeWebviewResizesContent': testResizeWebviewResizesContent, | 1750 'testResizeWebviewResizesContent': testResizeWebviewResizesContent, |
1773 'testTerminateAfterExit': testTerminateAfterExit, | 1751 'testTerminateAfterExit': testTerminateAfterExit, |
1774 'testWebRequestAPI': testWebRequestAPI, | 1752 'testWebRequestAPI': testWebRequestAPI, |
1775 'testWebRequestAPIWithHeaders': testWebRequestAPIWithHeaders, | 1753 'testWebRequestAPIWithHeaders': testWebRequestAPIWithHeaders, |
1776 'testWebRequestAPIExistence': testWebRequestAPIExistence, | 1754 'testWebRequestAPIExistence': testWebRequestAPIExistence, |
1777 'testWebRequestAPIGoogleProperty': testWebRequestAPIGoogleProperty, | 1755 'testWebRequestAPIGoogleProperty': testWebRequestAPIGoogleProperty |
1778 'testCaptureVisibleRegion' : testCaptureVisibleRegion | |
1779 }; | 1756 }; |
1780 | 1757 |
1781 onload = function() { | 1758 onload = function() { |
1782 chrome.test.getConfig(function(config) { | 1759 chrome.test.getConfig(function(config) { |
1783 embedder.setUp_(config); | 1760 embedder.setUp_(config); |
1784 chrome.test.sendMessage('LAUNCHED'); | 1761 chrome.test.sendMessage('LAUNCHED'); |
1785 }); | 1762 }); |
1786 }; | 1763 }; |
OLD | NEW |