OLD | NEW |
1 function log(s) | 1 function log(s) |
2 { | 2 { |
3 document.getElementById("console").appendChild(document.createTextNode(s + "
\n")); | 3 document.getElementById("console").appendChild(document.createTextNode(s + "
\n")); |
4 } | 4 } |
5 | 5 |
6 function shouldBe(a, b, shouldNotPrintValues) | 6 function shouldBe(a, b, shouldNotPrintValues) |
7 { | 7 { |
8 var evalA, evalB; | 8 var evalA, evalB; |
9 try { | 9 try { |
10 evalA = eval(a); | 10 evalA = eval(a); |
(...skipping 16 matching lines...) Expand all Loading... |
27 message += ": " + a + " matched the expected value."; | 27 message += ": " + a + " matched the expected value."; |
28 } | 28 } |
29 } else { | 29 } else { |
30 message = "*** FAIL: " + a + " should be '" + evalB + "' but instead is "
+ evalA + ". ***"; | 30 message = "*** FAIL: " + a + " should be '" + evalB + "' but instead is "
+ evalA + ". ***"; |
31 } | 31 } |
32 | 32 |
33 message = String(message).replace(/\n/g, ""); | 33 message = String(message).replace(/\n/g, ""); |
34 log(message); | 34 log(message); |
35 } | 35 } |
36 | 36 |
37 function shouldBeTrue(a) | 37 function shouldBeTrue(a) |
38 { | 38 { |
39 shouldBe(a, "true"); | 39 shouldBe(a, "true"); |
40 } | 40 } |
41 | 41 |
42 function shouldBeFalse(b) | 42 function shouldBeFalse(b) |
43 { | 43 { |
44 shouldBe(b, "false"); | 44 shouldBe(b, "false"); |
45 } | 45 } |
46 | 46 |
47 function shouldBeUndefined(b) | 47 function shouldBeUndefined(b) |
48 { | 48 { |
49 shouldBe(b, "undefined"); | 49 shouldBe(b, "undefined"); |
50 } | 50 } |
51 | 51 |
52 function canGet(keyPath) | 52 function canGet(keyPath) |
53 { | 53 { |
54 try { | 54 try { |
55 return eval("window." + keyPath) !== undefined; | 55 return eval("window." + keyPath) !== undefined; |
56 } catch(e) { | 56 } catch(e) { |
57 return false; | 57 return false; |
58 } | 58 } |
59 } | 59 } |
(...skipping 26 matching lines...) Expand all Loading... |
86 return true; | 86 return true; |
87 } | 87 } |
88 } | 88 } |
89 | 89 |
90 function canGetDescriptor(target, property) | 90 function canGetDescriptor(target, property) |
91 { | 91 { |
92 try { | 92 try { |
93 var desc = Object.getOwnPropertyDescriptor(target, property); | 93 var desc = Object.getOwnPropertyDescriptor(target, property); |
94 // To deal with an idiosyncrasy in how binding objects work in conjuncti
on with | 94 // To deal with an idiosyncrasy in how binding objects work in conjuncti
on with |
95 // slot and descriptor delegates we also allow descriptor with undefined
value/getter/setter | 95 // slot and descriptor delegates we also allow descriptor with undefined
value/getter/setter |
96 return desc !== undefined && (desc.value !== undefined || desc.get !==
undefined || desc.set !== undefined); | 96 return desc !== undefined && (desc.value !== undefined || desc.get !== u
ndefined || desc.set !== undefined); |
97 } catch(e) { | 97 } catch(e) { |
98 return false; | 98 return false; |
99 } | 99 } |
100 } | 100 } |
101 | 101 |
102 window.marker = { }; | 102 window.marker = { }; |
103 | 103 |
104 function canSet(keyPath, valuePath) | 104 function canSet(keyPath, valuePath) |
105 { | 105 { |
106 if (valuePath === undefined) | 106 if (valuePath === undefined) |
(...skipping 14 matching lines...) Expand all Loading... |
121 return true; | 121 return true; |
122 } catch(e) { | 122 } catch(e) { |
123 return false; | 123 return false; |
124 } | 124 } |
125 } | 125 } |
126 | 126 |
127 function toString(expression, valueForException) | 127 function toString(expression, valueForException) |
128 { | 128 { |
129 if (valueForException === undefined) | 129 if (valueForException === undefined) |
130 valueForException = "[exception]"; | 130 valueForException = "[exception]"; |
131 | 131 |
132 try { | 132 try { |
133 var evalExpression = eval(expression); | 133 var evalExpression = eval(expression); |
134 if (evalExpression === undefined) | 134 if (evalExpression === undefined) |
135 throw null; | 135 throw null; |
136 return String(evalExpression); | 136 return String(evalExpression); |
137 } catch(e) { | 137 } catch(e) { |
138 return valueForException; | 138 return valueForException; |
139 } | 139 } |
140 } | 140 } |
141 | 141 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
229 function doneHandler() { | 229 function doneHandler() { |
230 if (win.closed) { | 230 if (win.closed) { |
231 if (window.testRunner) | 231 if (window.testRunner) |
232 testRunner.notifyDone(); | 232 testRunner.notifyDone(); |
233 return; | 233 return; |
234 } | 234 } |
235 | 235 |
236 setTimeout(doneHandler, 5); | 236 setTimeout(doneHandler, 5); |
237 } | 237 } |
238 } | 238 } |
OLD | NEW |