| 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( |
| 1696 {}, |
| 1697 function(imgdata) { |
| 1698 if (chrome.runtime.lastError) { |
| 1699 console.log( |
| 1700 'webview.apitest.testCaptureVisibleRegion: ' + |
| 1701 chrome.runtime.lastError.message); |
| 1702 embedder.test.fail(); |
| 1703 } else { |
| 1704 if (imgdata.indexOf('data:image/jpeg;base64') != 0) { |
| 1705 console_log('imgdata = ' + imgdata); |
| 1706 } |
| 1707 embedder.test.assertTrue( |
| 1708 imgdata.indexOf('data:image/jpeg;base64') == 0); |
| 1709 embedder.test.succeed(); |
| 1710 } |
| 1711 }); |
| 1712 }); |
| 1713 document.body.appendChild(webview); |
| 1714 } |
| 1715 |
| 1716 function captureVisibleRegionDoCapture() {} |
| 1717 |
| 1688 // Tests end. | 1718 // Tests end. |
| 1689 | 1719 |
| 1690 embedder.test.testList = { | 1720 embedder.test.testList = { |
| 1691 'testAllowTransparencyAttribute': testAllowTransparencyAttribute, | 1721 'testAllowTransparencyAttribute': testAllowTransparencyAttribute, |
| 1692 'testAPIMethodExistence': testAPIMethodExistence, | 1722 'testAPIMethodExistence': testAPIMethodExistence, |
| 1693 'testAssignSrcAfterCrash': testAssignSrcAfterCrash, | 1723 'testAssignSrcAfterCrash': testAssignSrcAfterCrash, |
| 1694 'testAutosizeAfterNavigation': testAutosizeAfterNavigation, | 1724 'testAutosizeAfterNavigation': testAutosizeAfterNavigation, |
| 1695 'testAutosizeBeforeNavigation': testAutosizeBeforeNavigation, | 1725 'testAutosizeBeforeNavigation': testAutosizeBeforeNavigation, |
| 1696 'testAutosizeHeight': testAutosizeHeight, | 1726 'testAutosizeHeight': testAutosizeHeight, |
| 1697 'testAutosizeRemoveAttributes': testAutosizeRemoveAttributes, | 1727 'testAutosizeRemoveAttributes': testAutosizeRemoveAttributes, |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1745 'testReload': testReload, | 1775 'testReload': testReload, |
| 1746 'testReloadAfterTerminate': testReloadAfterTerminate, | 1776 'testReloadAfterTerminate': testReloadAfterTerminate, |
| 1747 'testRemoveSrcAttribute': testRemoveSrcAttribute, | 1777 'testRemoveSrcAttribute': testRemoveSrcAttribute, |
| 1748 'testRemoveWebviewAfterNavigation': testRemoveWebviewAfterNavigation, | 1778 'testRemoveWebviewAfterNavigation': testRemoveWebviewAfterNavigation, |
| 1749 'testRemoveWebviewOnExit': testRemoveWebviewOnExit, | 1779 'testRemoveWebviewOnExit': testRemoveWebviewOnExit, |
| 1750 'testResizeWebviewResizesContent': testResizeWebviewResizesContent, | 1780 'testResizeWebviewResizesContent': testResizeWebviewResizesContent, |
| 1751 'testTerminateAfterExit': testTerminateAfterExit, | 1781 'testTerminateAfterExit': testTerminateAfterExit, |
| 1752 'testWebRequestAPI': testWebRequestAPI, | 1782 'testWebRequestAPI': testWebRequestAPI, |
| 1753 'testWebRequestAPIWithHeaders': testWebRequestAPIWithHeaders, | 1783 'testWebRequestAPIWithHeaders': testWebRequestAPIWithHeaders, |
| 1754 'testWebRequestAPIExistence': testWebRequestAPIExistence, | 1784 'testWebRequestAPIExistence': testWebRequestAPIExistence, |
| 1755 'testWebRequestAPIGoogleProperty': testWebRequestAPIGoogleProperty | 1785 'testWebRequestAPIGoogleProperty': testWebRequestAPIGoogleProperty, |
| 1786 'testCaptureVisibleRegion': testCaptureVisibleRegion |
| 1756 }; | 1787 }; |
| 1757 | 1788 |
| 1758 onload = function() { | 1789 onload = function() { |
| 1759 chrome.test.getConfig(function(config) { | 1790 chrome.test.getConfig(function(config) { |
| 1760 embedder.setUp_(config); | 1791 embedder.setUp_(config); |
| 1761 chrome.test.sendMessage('LAUNCHED'); | 1792 chrome.test.sendMessage('LAUNCHED'); |
| 1762 }); | 1793 }); |
| 1763 }; | 1794 }; |
| OLD | NEW |