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

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

Issue 1221483002: New tabCapture.captureOffscreenTab API, initially for Presentation API 1UA mode (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Mostly revert to Patch Set 6, plus minor tweaks. [and REBASE] Created 5 years, 2 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
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Waits until content sampled from |stream| indicates a success or fail status
6 // from an off-screen tab page that renders a green (success) or red (fail)
7 // color fill.
8 function waitForGreenOrRedTestResultAndEndTest(stream) {
9 waitForAnExpectedColor(stream, [[255, 0, 0], [0, 255, 0]], 64,
10 function (result) {
11 stopAllTracks(stream);
12 if (result == 1) {
13 chrome.test.succeed();
14 } else {
15 // Fail after 3 seconds to allow examining the debug error message.
16 setTimeout(function () { chrome.test.fail(); }, 3000);
17 }
18 }
19 );
20 }
21
22 chrome.test.runTests([
23 function cannotAccessLocalResources() {
24 chrome.tabCapture.captureOffscreenTab(
25 makeDataUriFromDocument(makeOffscreenTabTestDocument(
26 'function failIfIsLoadable(url, runNextTest) {\n' +
27 ' var request = new XMLHttpRequest();\n' +
28 ' request.open("GET", url);\n' +
29 ' request.addEventListener("load", function () {\n' +
30 ' setDebugMessage(url);\n' +
31 ' setFillColor(redColor);\n' +
32 ' });\n' +
33 ' request.addEventListener("error", function () {\n' +
34 ' setTimeout(runNextTest, 0);\n' +
35 ' });' +
36 ' request.send();\n' +
37 '}\n' +
38 '\n' +
39 'failIfIsLoadable("file://something", function () {\n' +
40 ' failIfIsLoadable("chrome-extension://' + chrome.runtime.id +
41 '/offscreen_evil_tests.js", function() {\n' +
42 ' setFillColor(greenColor);\n' +
43 ' });\n' +
44 '});')),
45 getCaptureOptions(),
46 waitForGreenOrRedTestResultAndEndTest);
47 },
48
49 function cannotOpenNewTabsOrDialogs() {
50 chrome.tabCapture.captureOffscreenTab(
51 makeDataUriFromDocument(makeOffscreenTabTestDocument(
52 'var wnd = window.open("data:text/html;charset=UTF-8,NOT SEEN");\n' +
53 'if (wnd) {\n' +
54 ' setDebugMessage("window.open() succeeded");\n' +
55 ' setFillColor(redColor);\n' +
56 '} else {\n' +
57 ' var result = window.confirm("Can you see me?");\n' +
58 ' if (result) {\n' +
59 ' setDebugMessage("positive confirm result");\n' +
60 ' setFillColor(redColor);\n' +
61 ' } else {\n' +
62 ' setFillColor(greenColor);\n' +
63 ' }\n' +
64 '}')),
65 getCaptureOptions(),
66 waitForGreenOrRedTestResultAndEndTest);
67 },
68
69 function cannotGetUserMedia() {
70 chrome.tabCapture.captureOffscreenTab(
71 makeDataUriFromDocument(makeOffscreenTabTestDocument(
72 'navigator.webkitGetUserMedia(\n' +
73 ' {video: true},\n' +
74 ' function onSuccess(stream) { setFillColor(redColor); },\n' +
75 ' function onFailure(error) { setFillColor(greenColor); });')),
76 getCaptureOptions(),
77 waitForGreenOrRedTestResultAndEndTest);
78 },
79
80 // NOTE: Before adding any more tests, the maximum off-screen tab limit would
81 // have to be increased (or a design issue resolved). This is because
82 // off-screen tabs are not closed the instant the LocalMediaStream is stopped,
83 // but approximately 1 second later.
84
85 ]);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698