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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/canvas/OffScreenCanvas-invalid-args.html

Issue 1488763002: Start an empty interface OffScreenCanvas (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: better -1 handling and more invalid args test cases Created 5 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 <!DOCTYPE html>
2 <script src="../../resources/js-test.js"></script>
3 <script>
4 description("Tests that the OffScreenCanvas can handle invalid arguments");
5
6 // Since blink uses signed int internally, this case tests how the constructor
7 // responds to the arguments that are larger than INT_MAX which would cause
8 // overflow. The current implementation is expected to clamp.
9 var setWidth = Math.pow(2, 31);
10 var setHeight = Math.pow(2, 31);
11 var obj = {Name: "John Doe", Age: 30};
12
13 var canvas1 = new OffScreenCanvas(setWidth, setHeight);
14 shouldBe("canvas1.width", "setWidth-1");
15 shouldBe("canvas1.height", "setHeight-1");
16
17 canvas1.width = null;
18 canvas1.height = null;
19 shouldBe("canvas1.width", "0");
20 shouldBe("canvas1.height", "0");
21
22 var didThrow = false;
23 try {
24 var canvas2 = new OffScreenCanvas(-1, -1);
25 } catch(e) {
26 didThrow = true;
27 testPassed("OffScreenCanvas(-1, -1) throws an exception as expected: " + e);
28 }
29 if (!didThrow)
30 testFailed("OffScreenCanvas(-1, -1) should throw an exception but did not.") ;
31
32 var canvas3 = new OffScreenCanvas(null, null);
33 shouldBe("canvas3.width", "0");
34 shouldBe("canvas3.height", "0");
35
36 canvas3.width = setWidth;
37 canvas3.height = setHeight;
38 shouldBe("canvas3.width", "setWidth-1");
39 shouldBe("canvas3.height", "setHeight-1");
40
41 try {
42 canvas3.width = -1;
Justin Novosad 2015/12/04 04:37:41 Use the helper function "shouldThrow" instead of a
43 } catch(e) {
44 didThrow = true;
45 testPassed("Setting width to -1 throws an exception as expected: " + e);
46 }
47 if (!didThrow)
48 testFailed("Setting width to -1 should throw an exception but did not.");
49
50 try {
51 canvas3.width = obj;
52 } catch(e) {
53 didThrow = true;
54 testPassed("Setting width to an object throws an exception as expected: " + e);
55 }
56 if (!didThrow)
57 testFailed("Setting width to an object should throw an exception but did not .");
58
59 try {
60 var canvas4 = new OffScreenCanvas(obj, obj);
61 } catch(e) {
62 didThrow = true;
63 testPassed("OffScreenCanvas(object, object) throws an exception as expected: " + e);
64 }
65 if (!didThrow)
66 testFailed("OffScreenCanvas(object, object) should throw an exception but di d not");
67
68 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698