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

Side by Side Diff: LayoutTests/fast/canvas/canvas-context-attributes-default-value.html

Issue 795833004: Use dictionaries for context creation attributes. Eliminate custom bindings. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased. Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | LayoutTests/fast/canvas/canvas-context-attributes-default-value-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <script src="../../resources/js-test.js"></script> 4 <script src="../../resources/js-test.js"></script>
5 <script> 5 <script>
6 6
7 var checkAttributes = { 7 var trueAttributes = {
8 alpha : true, 8 alpha : true,
9 }; 9 };
10 10
11 var falseAttributes = {
12 alpha : false,
13 };
14
11 function testAttributes(expectedAttributes, checkValue) { 15 function testAttributes(expectedAttributes, checkValue) {
12 16
13 if (arguments.length != 1 && arguments.length != 2) 17 if (arguments.length != 1 && arguments.length != 2)
14 return; 18 return;
15 19
16 var canvas = document.createElement("canvas"); 20 var canvas = document.createElement("canvas");
17 var initialAttributes = {}; 21 var initialAttributes = {};
18 var isUndefinedOrNull = arguments.length == 2 && 22 var isUndefinedOrNull = arguments.length == 2 &&
19 (checkValue == undefined || checkValue == null); 23 (checkValue == undefined || checkValue == null);
20 24
21 if (isUndefinedOrNull) 25 if (isUndefinedOrNull)
22 for (key in expectedAttributes) 26 for (key in expectedAttributes)
23 initialAttributes[key] = checkValue; 27 initialAttributes[key] = checkValue;
24 28
25 var context = canvas.getContext("2d", initialAttributes); 29 var context = canvas.getContext("2d", initialAttributes);
26 30
27 window.actualContextAttributes = context.getContextAttributes(); 31 window.actualContextAttributes = context.getContextAttributes();
28 32
29 for (key in expectedAttributes) 33 for (key in expectedAttributes)
30 shouldBe("actualContextAttributes." + key, 34 shouldBe("actualContextAttributes." + key,
31 expectedAttributes[key].toString()); 35 expectedAttributes[key].toString());
32 } 36 }
33 37
34 </script> 38 </script>
35 </head> 39 </head>
36 <body> 40 <body>
37 <script> 41 <script>
38 42
39 debug("Testing default value:"); 43 debug("Testing default value:");
40 testAttributes(checkAttributes); 44 testAttributes(trueAttributes);
41 debug("") 45 debug("")
42 46
43 debug("Testing undefined value:"); 47 debug("Testing undefined value:");
44 testAttributes(checkAttributes, undefined); 48 testAttributes(trueAttributes, undefined);
45 debug("") 49 debug("")
46 50
47 debug("Testing null value:"); 51 debug("Testing null value:");
48 testAttributes(checkAttributes, null); 52 testAttributes(falseAttributes, null);
49 debug("") 53 debug("")
50 54
51 </script> 55 </script>
52 </body> 56 </body>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/fast/canvas/canvas-context-attributes-default-value-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698