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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/extensions/api_test/tab_capture/offscreen_evil_tests.js
diff --git a/chrome/test/data/extensions/api_test/tab_capture/offscreen_evil_tests.js b/chrome/test/data/extensions/api_test/tab_capture/offscreen_evil_tests.js
new file mode 100644
index 0000000000000000000000000000000000000000..f3f822f0fdf280e31f9db047e1a95fd47cde9a1d
--- /dev/null
+++ b/chrome/test/data/extensions/api_test/tab_capture/offscreen_evil_tests.js
@@ -0,0 +1,85 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Waits until content sampled from |stream| indicates a success or fail status
+// from an off-screen tab page that renders a green (success) or red (fail)
+// color fill.
+function waitForGreenOrRedTestResultAndEndTest(stream) {
+ waitForAnExpectedColor(stream, [[255, 0, 0], [0, 255, 0]], 64,
+ function (result) {
+ stopAllTracks(stream);
+ if (result == 1) {
+ chrome.test.succeed();
+ } else {
+ // Fail after 3 seconds to allow examining the debug error message.
+ setTimeout(function () { chrome.test.fail(); }, 3000);
+ }
+ }
+ );
+}
+
+chrome.test.runTests([
+ function cannotAccessLocalResources() {
+ chrome.tabCapture.captureOffscreenTab(
+ makeDataUriFromDocument(makeOffscreenTabTestDocument(
+ 'function failIfIsLoadable(url, runNextTest) {\n' +
+ ' var request = new XMLHttpRequest();\n' +
+ ' request.open("GET", url);\n' +
+ ' request.addEventListener("load", function () {\n' +
+ ' setDebugMessage(url);\n' +
+ ' setFillColor(redColor);\n' +
+ ' });\n' +
+ ' request.addEventListener("error", function () {\n' +
+ ' setTimeout(runNextTest, 0);\n' +
+ ' });' +
+ ' request.send();\n' +
+ '}\n' +
+ '\n' +
+ 'failIfIsLoadable("file://something", function () {\n' +
+ ' failIfIsLoadable("chrome-extension://' + chrome.runtime.id +
+ '/offscreen_evil_tests.js", function() {\n' +
+ ' setFillColor(greenColor);\n' +
+ ' });\n' +
+ '});')),
+ getCaptureOptions(),
+ waitForGreenOrRedTestResultAndEndTest);
+ },
+
+ function cannotOpenNewTabsOrDialogs() {
+ chrome.tabCapture.captureOffscreenTab(
+ makeDataUriFromDocument(makeOffscreenTabTestDocument(
+ 'var wnd = window.open("data:text/html;charset=UTF-8,NOT SEEN");\n' +
+ 'if (wnd) {\n' +
+ ' setDebugMessage("window.open() succeeded");\n' +
+ ' setFillColor(redColor);\n' +
+ '} else {\n' +
+ ' var result = window.confirm("Can you see me?");\n' +
+ ' if (result) {\n' +
+ ' setDebugMessage("positive confirm result");\n' +
+ ' setFillColor(redColor);\n' +
+ ' } else {\n' +
+ ' setFillColor(greenColor);\n' +
+ ' }\n' +
+ '}')),
+ getCaptureOptions(),
+ waitForGreenOrRedTestResultAndEndTest);
+ },
+
+ function cannotGetUserMedia() {
+ chrome.tabCapture.captureOffscreenTab(
+ makeDataUriFromDocument(makeOffscreenTabTestDocument(
+ 'navigator.webkitGetUserMedia(\n' +
+ ' {video: true},\n' +
+ ' function onSuccess(stream) { setFillColor(redColor); },\n' +
+ ' function onFailure(error) { setFillColor(greenColor); });')),
+ getCaptureOptions(),
+ waitForGreenOrRedTestResultAndEndTest);
+ },
+
+ // NOTE: Before adding any more tests, the maximum off-screen tab limit would
+ // have to be increased (or a design issue resolved). This is because
+ // off-screen tabs are not closed the instant the LocalMediaStream is stopped,
+ // but approximately 1 second later.
+
+]);

Powered by Google App Engine
This is Rietveld 408576698