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

Unified Diff: chrome/test/data/extensions/api_test/streams_private/handle_mime_type/background.js

Issue 281513003: Implement chrome.streamsPrivate.abort() extensions function (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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/streams_private/handle_mime_type/background.js
diff --git a/chrome/test/data/extensions/api_test/streams_private/handle_mime_type/background.js b/chrome/test/data/extensions/api_test/streams_private/handle_mime_type/background.js
index d7ccdd8de897464d6534f011927d388c50539132..0d791d499fb70892b5e4c86c2f575639093a36bc 100644
--- a/chrome/test/data/extensions/api_test/streams_private/handle_mime_type/background.js
+++ b/chrome/test/data/extensions/api_test/streams_private/handle_mime_type/background.js
@@ -51,6 +51,42 @@ chrome.streamsPrivate.onExecuteMimeTypeHandler.addListener(
return;
}
+ // StreamsPrivateApiTest.Abort uses the application/pdf type to test aborting
+ // the stream.
+ if (params.mimeType == 'application/rtf') {
+ var url = params.originalUrl.split('/');
+ var filename = url[url.length - 1];
+ if (filename == 'no_abort.rtf') {
+ // Test a stream URL can be fetched properly.
+ var xhr = new XMLHttpRequest();
+ xhr.open("GET", params.streamUrl, false);
+ xhr.send(null);
+ if (xhr.status == 200) {
+ chrome.test.notifyPass();
+ } else {
+ chrome.test.notifyFail(
+ 'Expected a stream URL response of 200, got ' + xhr.status + '.');
+ hasFailed = true;
+ }
+ }
+ if (filename == 'abort.rtf') {
+ // Test a stream URL fails to be fetched if it is aborted.
+ chrome.streamsPrivate.abort(params.streamUrl, function() {
+ var xhr = new XMLHttpRequest();
+ xhr.open("GET", params.streamUrl, false);
+ xhr.send(null);
+ if (xhr.status == 404) {
+ chrome.test.notifyPass();
+ } else {
+ chrome.test.notifyFail(
+ 'Expected a stream URL response of 404, got ' + xhr.status + '.');
+ hasFailed = true;
+ }
+ });
+ }
+ return;
+ }
+
// MIME type 'test/done' is received only when tests for which no events
// should be raised to notify the extension it's job is done. If the extension
// receives the 'test/done' and there were no previous failures, notify that

Powered by Google App Engine
This is Rietveld 408576698