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

Side by Side Diff: chrome/test/data/extensions/api_test/page_capture/test.js

Issue 2552203007: Public Sessions - prompt the user for pageCapture requests (Closed)
Patch Set: Nitfix Created 3 years, 10 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 (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 // API test for chrome.extension.pageCapture. 5 // API test for chrome.extension.pageCapture.
6 // browser_tests.exe --gtest_filter=ExtensionApiTest.PageCapture 6 // browser_tests.exe --gtest_filter=ExtensionPageCaptureApiTest.*
7 7
8 const assertEq = chrome.test.assertEq; 8 const assertEq = chrome.test.assertEq;
9 const assertTrue = chrome.test.assertTrue; 9 const assertTrue = chrome.test.assertTrue;
10 10
11 var testUrl = 'http://www.a.com:PORT' + 11 var testUrl = 'http://www.a.com:PORT' +
12 '/extensions/api_test/page_capture/google.html'; 12 '/extensions/api_test/page_capture/google.html';
13 13
14 function waitForCurrentTabLoaded(callback) { 14 function waitForCurrentTabLoaded(callback) {
15 chrome.tabs.getSelected(null, function(tab) { 15 chrome.tabs.getSelected(null, function(tab) {
16 if (tab.status == "complete" && tab.url == testUrl) { 16 if (tab.status == "complete" && tab.url == testUrl) {
17 callback(); 17 callback();
18 return; 18 return;
19 } 19 }
20 window.setTimeout(function() { waitForCurrentTabLoaded(callback); }, 100); 20 window.setTimeout(function() { waitForCurrentTabLoaded(callback); }, 100);
21 }); 21 });
22 } 22 }
23 23
24 chrome.test.getConfig(function(config) { 24 chrome.test.getConfig(function(config) {
25 testUrl = testUrl.replace(/PORT/, config.testServer.port); 25 testUrl = testUrl.replace(/PORT/, config.testServer.port);
26 26
27 chrome.test.runTests([ 27 chrome.test.runTests([
28 function saveAsMHTML() { 28 function saveAsMHTML() {
29 chrome.tabs.getSelected(null, function(tab) { 29 chrome.tabs.getSelected(null, function(tab) {
30 chrome.tabs.update(null, { "url": testUrl }); 30 chrome.tabs.update(null, { "url": testUrl });
31 waitForCurrentTabLoaded(function() { 31 waitForCurrentTabLoaded(function() {
32 chrome.pageCapture.saveAsMHTML({ "tabId": tab.id }, 32 chrome.pageCapture.saveAsMHTML({ "tabId": tab.id },
33 function(data) { 33 function(data) {
34 if (config.customArg == "REQUEST_DENIED") {
35 chrome.test.assertLastError("User denied request.");
36 chrome.test.notifyPass();
37 return;
38 }
34 assertEq(undefined, chrome.runtime.lastError); 39 assertEq(undefined, chrome.runtime.lastError);
35 assertTrue(data != null); 40 assertTrue(data != null);
36 // It should contain few KBs of data. 41 // It should contain few KBs of data.
37 assertTrue(data.size > 100); 42 assertTrue(data.size > 100);
38 // Let's make sure it contains some well known strings. 43 // Let's make sure it contains some well known strings.
39 var reader = new FileReader(); 44 var reader = new FileReader();
40 reader.onload = function(e) { 45 reader.onload = function(e) {
41 var text = e.target.result; 46 var text = e.target.result;
42 assertTrue(text.indexOf(testUrl) != -1); 47 assertTrue(text.indexOf(testUrl) != -1);
43 assertTrue(text.indexOf("logo.png") != -1); 48 assertTrue(text.indexOf("logo.png") != -1);
44 // Run the GC so the blob is deleted. 49 // Run the GC so the blob is deleted.
45 window.setTimeout(function() { window.gc(); }); 50 window.setTimeout(function() { window.gc(); });
46 window.setTimeout(function() { chrome.test.notifyPass(); }, 0); 51 window.setTimeout(function() { chrome.test.notifyPass(); }, 0);
47 }; 52 };
48 reader.readAsText(data); 53 reader.readAsText(data);
49 }); 54 });
50 }); 55 });
51 }); 56 });
52 } 57 }
53 ]); 58 ]);
54 }); 59 });
55 60
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698