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

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

Issue 2379573008: Add SetImageData api to chrome.clipboard. (Closed)
Patch Set: Add a warning in clipboard.idl about the future deprecation plan. Created 4 years 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 2016 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 // Test clipboard extension api chrome.clipboard.onClipboardDataChanged event.
6
7 var testSuccessCount = 0;
8
9 function testSetImageDataClipboard(imageUrl, imageType, expectSucceed) {
10 var oReq = new XMLHttpRequest();
11 oReq.open("GET", imageUrl, true);
Devlin 2016/12/16 02:26:16 single quotes in js.
jennyz 2016/12/19 07:01:36 Done.
12 oReq.responseType = "arraybuffer";
13
14 oReq.onload = function (oEvent) {
15 var arrayBuffer = oReq.response;
16 var binaryString = '';
17
18 if (arrayBuffer) {
19 chrome.clipboard.setImageData(arrayBuffer, imageType, function() {
20 chrome.test.assertEq(expectSucceed, !chrome.runtime.lastError);
21 chrome.test.succeed();
22 });
23 } else {
24 chrome.test.fail('Failed to load the png image file');
25 }
26 };
27
28 oReq.send(null);
29 }
30
31 function testSavePngImageToClipboard(baseUrl) {
32 testSetImageDataClipboard(baseUrl + '/icon1.png', 'png', true);
33 }
34
35 function testSaveJpegImageToClipboard(baseUrl) {
36 testSetImageDataClipboard(baseUrl + '/test.jpg', 'jpeg', true);
37 }
38
39 function testSaveBadImageData(baseUrl) {
40 testSetImageDataClipboard(baseUrl + '/redirect_target.gif', 'jpeg', false);
41 }
42
43 function bindTest(test, param) {
44 var result = test.bind(null, param);
45 result.generatedName = test.name;
46 return result;
47 }
48
49 chrome.test.getConfig(function(config) {
50 var baseUrl = 'http://localhost:' + config.testServer.port + '/extensions';
51 chrome.test.runTests([
52 bindTest(testSavePngImageToClipboard, baseUrl),
53 bindTest(testSaveJpegImageToClipboard, baseUrl),
54 bindTest(testSaveBadImageData, baseUrl)
55 ]);
56 })
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698