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

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

Powered by Google App Engine
This is Rietveld 408576698