Wed, 31 Dec 2014 06:55:50 +0100
Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2
michael@0 | 1 | <html> |
michael@0 | 2 | <head> |
michael@0 | 3 | <script type="text/javascript"> |
michael@0 | 4 | function assert(cond, msg) { if (!cond) { throw msg; } } |
michael@0 | 5 | window.onload = function() { |
michael@0 | 6 | try { |
michael@0 | 7 | var ctx = document.getElementById("c1").getContext("2d"); |
michael@0 | 8 | |
michael@0 | 9 | assert(null === ctx.mozDash, |
michael@0 | 10 | "Default dash is null (no dash)"); |
michael@0 | 11 | assert(0 == ctx.mozDashOffset, |
michael@0 | 12 | "Default dashOffset is 0 (no dash)"); |
michael@0 | 13 | |
michael@0 | 14 | ctx.mozDash = [ 2 ]; |
michael@0 | 15 | assert(1 == ctx.mozDash.length && 2 == ctx.mozDash[0], |
michael@0 | 16 | "dash = [ 2 ] works"); |
michael@0 | 17 | ctx.mozDash = null; |
michael@0 | 18 | assert(null === ctx.mozDash, |
michael@0 | 19 | "dash = null resets to null"); |
michael@0 | 20 | ctx.mozDash = [ 2 ]; |
michael@0 | 21 | ctx.mozDash = undefined; |
michael@0 | 22 | assert(null === ctx.mozDash, |
michael@0 | 23 | "dash = undefined resets to null"); |
michael@0 | 24 | ctx.mozDash = [ 2 ]; |
michael@0 | 25 | ctx.mozDash = [ ]; |
michael@0 | 26 | assert(null === ctx.mozDash, |
michael@0 | 27 | "dash = [] resets to null"); |
michael@0 | 28 | |
michael@0 | 29 | ctx.mozDash = [ 2 ]; |
michael@0 | 30 | assert(0 == ctx.mozDashOffset, "dashOffset is 0"); |
michael@0 | 31 | ctx.mozDashOffset = 1; |
michael@0 | 32 | assert(1 == ctx.mozDashOffset, "Setting dashOffset succeeded"); |
michael@0 | 33 | ctx.mozDash = null; |
michael@0 | 34 | assert(0 == ctx.mozDashOffset, "Disabling dash resets dashOffset"); |
michael@0 | 35 | ctx.mozDash = [ 2 ]; |
michael@0 | 36 | assert(0 == ctx.mozDashOffset, "Previous dashOffset isn't remembered"); |
michael@0 | 37 | ctx.mozDash = null; |
michael@0 | 38 | |
michael@0 | 39 | // NB: might want to add a |.dash = number| special case, |
michael@0 | 40 | // don't test that it fails here. Might also want to add a |
michael@0 | 41 | // |.dash = [0]| special case for resetting, so don't test |
michael@0 | 42 | // that either. |
michael@0 | 43 | var badVals = [ -1, |
michael@0 | 44 | "string", |
michael@0 | 45 | /* According to the WebIDL sequence-ifying |
michael@0 | 46 | * (really they mean array-ifying here) |
michael@0 | 47 | * algorithm, objects without .length |
michael@0 | 48 | * properties convert to a 0-length arrays. |
michael@0 | 49 | * This seems ... odd, since by the book we're |
michael@0 | 50 | * forced to accept |ctx.dash = Function|, |
michael@0 | 51 | * e.g., but there it is. |
michael@0 | 52 | */ |
michael@0 | 53 | // { obj: true }, |
michael@0 | 54 | [ "array of string" ], |
michael@0 | 55 | [ -1 ], |
michael@0 | 56 | [ 0, 0, 0 ], |
michael@0 | 57 | [ 2, "string" ], |
michael@0 | 58 | ]; |
michael@0 | 59 | ctx.mozDash = [ 2 ]; |
michael@0 | 60 | for (var i = 0; i < badVals.length; ++i) { |
michael@0 | 61 | var error = false; |
michael@0 | 62 | try { ctx.mozDash = badVals[i]; } |
michael@0 | 63 | catch(e) { error = true; } |
michael@0 | 64 | assert(error && 1 == ctx.mozDash.length && 2 == ctx.mozDash[0], |
michael@0 | 65 | "Expected |dash = "+ badVals[i] +"| to throw exception and not change .dash"); |
michael@0 | 66 | } |
michael@0 | 67 | ctx.mozDash = null; |
michael@0 | 68 | |
michael@0 | 69 | ctx.save(); |
michael@0 | 70 | ctx.mozDash = [ 2 ]; |
michael@0 | 71 | ctx.restore(); |
michael@0 | 72 | assert(null === ctx.mozDash, |
michael@0 | 73 | "dash was saved then restored"); |
michael@0 | 74 | } catch (e) { |
michael@0 | 75 | document.body.innerHTML = "FAIL: "+ e.toString(); |
michael@0 | 76 | return; |
michael@0 | 77 | } |
michael@0 | 78 | document.body.innerHTML = "Pass"; |
michael@0 | 79 | } |
michael@0 | 80 | </script> |
michael@0 | 81 | </head> |
michael@0 | 82 | <body> |
michael@0 | 83 | <div><canvas id="c1" width="300" height="300"></canvas></div> |
michael@0 | 84 | </body> |
michael@0 | 85 | </html> |