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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/shapedetection/shapedetection-security-test.html

Issue 2756793002: RELAND: Shape Detection: move the Mac service to the sandboxed GPU process (Closed)
Patch Set: moved shapedetection-security-test.html to non-fast LayoutTests to use the mock mojo service Created 3 years, 9 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 <!DOCTYPE html>
2 <script src=../../resources/testharness.js></script>
3 <script src=../../resources/testharnessreport.js></script>
4 <script>
5
6 // Returns a Promise that is resolve()d if detect() is rejected. Needs an input
7 // |element| (e.g. an HTMLImageElement or HTMLVideoElement) and a |url| to load.
8 function detectOnElementAndExpectError(createDetector, element, url) {
9 return new Promise(function(resolve, reject) {
10 var tryDetection = function() {
11 var detector = createDetector();
12 detector.detect(element)
13 .then(detectionResult => {
14 reject("Promise should have been rejected.");
15 })
16 .catch(error => {
17 resolve(error);
18 });
19 };
20 element.onload = tryDetection;
21 element.onerror = tryDetection;
22 element.src = url;
23 });
24 };
25
26 // This test verifies that a Detector will reject an undecodable image.
27 var createTestForBadImage = function(createDetector) {
28 promise_test(function(t) {
29 var image = new Image();
30 return detectOnElementAndExpectError(createDetector, image,
31 "../../external/wpt/images/broken.png")
32 .then(function(error) {
33 assert_equals(error.name, "InvalidStateError");
34 });
35 }, "Detector should reject undecodable images with an InvalidStateError.");
36 };
37
38 generate_tests(createTestForBadImage, [
39 [ "Face", () => { return new FaceDetector(); } ],
40 [ "Barcode", () => { return new BarcodeDetector(); } ],
41 [ "Text", () => { return new TextDetector(); } ]
42 ]);
43
44 // This test verifies that a Detector will reject a broken video.
45 var createTestForBadVideo = function(createDetector) {
46 promise_test(function(t) {
47 var video = document.createElement('video');
48 return detectOnElementAndExpectError(createDetector, video,
49 "content/garbage.webm")
50 .then(function(error) {
51 assert_equals(error.name, "InvalidStateError");
52 });
53 }, "Detector should reject undecodable videos with an InvalidStateError.");
54 };
55
56 generate_tests(createTestForBadVideo, [
57 [ "Face", () => { return new FaceDetector(); } ],
58 [ "Barcode", () => { return new BarcodeDetector(); } ],
59 [ "Text", () => { return new TextDetector(); } ]
60 ]);
61
62 </script>
OLDNEW
« no previous file with comments | « content/gpu/gpu_service_factory.cc ('k') | third_party/WebKit/LayoutTests/shapedetection/detection-security-test.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698