Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Side by Side Diff: extensions/test/data/web_view/apitest/main.js

Issue 1582053002: Implement webview.captureVisibleRegion() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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.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
1688 // Tests end. 1710 // Tests end.
1689 1711
1690 embedder.test.testList = { 1712 embedder.test.testList = {
1691 'testAllowTransparencyAttribute': testAllowTransparencyAttribute, 1713 'testAllowTransparencyAttribute': testAllowTransparencyAttribute,
1692 'testAPIMethodExistence': testAPIMethodExistence, 1714 'testAPIMethodExistence': testAPIMethodExistence,
1693 'testAssignSrcAfterCrash': testAssignSrcAfterCrash, 1715 'testAssignSrcAfterCrash': testAssignSrcAfterCrash,
1694 'testAutosizeAfterNavigation': testAutosizeAfterNavigation, 1716 'testAutosizeAfterNavigation': testAutosizeAfterNavigation,
1695 'testAutosizeBeforeNavigation': testAutosizeBeforeNavigation, 1717 'testAutosizeBeforeNavigation': testAutosizeBeforeNavigation,
1696 'testAutosizeHeight': testAutosizeHeight, 1718 'testAutosizeHeight': testAutosizeHeight,
1697 'testAutosizeRemoveAttributes': testAutosizeRemoveAttributes, 1719 'testAutosizeRemoveAttributes': testAutosizeRemoveAttributes,
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1745 'testReload': testReload, 1767 'testReload': testReload,
1746 'testReloadAfterTerminate': testReloadAfterTerminate, 1768 'testReloadAfterTerminate': testReloadAfterTerminate,
1747 'testRemoveSrcAttribute': testRemoveSrcAttribute, 1769 'testRemoveSrcAttribute': testRemoveSrcAttribute,
1748 'testRemoveWebviewAfterNavigation': testRemoveWebviewAfterNavigation, 1770 'testRemoveWebviewAfterNavigation': testRemoveWebviewAfterNavigation,
1749 'testRemoveWebviewOnExit': testRemoveWebviewOnExit, 1771 'testRemoveWebviewOnExit': testRemoveWebviewOnExit,
1750 'testResizeWebviewResizesContent': testResizeWebviewResizesContent, 1772 'testResizeWebviewResizesContent': testResizeWebviewResizesContent,
1751 'testTerminateAfterExit': testTerminateAfterExit, 1773 'testTerminateAfterExit': testTerminateAfterExit,
1752 'testWebRequestAPI': testWebRequestAPI, 1774 'testWebRequestAPI': testWebRequestAPI,
1753 'testWebRequestAPIWithHeaders': testWebRequestAPIWithHeaders, 1775 'testWebRequestAPIWithHeaders': testWebRequestAPIWithHeaders,
1754 'testWebRequestAPIExistence': testWebRequestAPIExistence, 1776 'testWebRequestAPIExistence': testWebRequestAPIExistence,
1755 'testWebRequestAPIGoogleProperty': testWebRequestAPIGoogleProperty 1777 'testWebRequestAPIGoogleProperty': testWebRequestAPIGoogleProperty,
1778 'testCaptureVisibleRegion' : testCaptureVisibleRegion
1756 }; 1779 };
1757 1780
1758 onload = function() { 1781 onload = function() {
1759 chrome.test.getConfig(function(config) { 1782 chrome.test.getConfig(function(config) {
1760 embedder.setUp_(config); 1783 embedder.setUp_(config);
1761 chrome.test.sendMessage('LAUNCHED'); 1784 chrome.test.sendMessage('LAUNCHED');
1762 }); 1785 });
1763 }; 1786 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698