Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / js / exception-thrown-from-equal.html
bloba65495fca36ee419ed94494b6b24b252f8c973bb
1 <p>This page tests whether primitive conversions during equality tests properly
2 throw exceptions. If the test passes, you'll see a series of PASS messages below.
3 </p>
4 <hr>
5 <pre id="console"></pre>
7 <script>
8 function log(s)
10 document.getElementById("console").appendChild(document.createTextNode(s + "\n"));
13 function shouldThrow(expression, exception, didCorrectlyThrow)
15 if (didCorrectlyThrow)
16 log("PASS: " + expression + " should throw a " + exception + ", and did.");
17 else
18 log("FAIL: " + expression + " should throw a " + exception + ", but didn't.");
21 if (window.testRunner)
22 testRunner.dumpAsText();
24 var o = {
25 valueOf: function() {
26 return { }; // should throw, because this is not a primitive value
29 toString: function() {
30 return { }; // should throw, because this is not a primitive value
34 shouldThrow("o == 'a'", "type error", (function() { try { o == 'a'; return false; } catch(e) { return e instanceof TypeError; } })());
35 shouldThrow("o != 'a'", "type error", (function() { try { o != 'a'; return false; } catch(e) { return e instanceof TypeError; } })());
36 shouldThrow("o == 0", "type error", (function() { try { o == 'a'; return false; } catch(e) { return e instanceof TypeError; } })());
37 shouldThrow("o != 0", "type error", (function() { try { o != 'a'; return false; } catch(e) { return e instanceof TypeError; } })());
38 </script>