Reviewers: metaweta,

Description:
From http://code.google.com/p/google-caja/issues/detail?id=513
    Check for each browser that '({}) instanceof x' throws if x is
    not a function. We are assuming that, because the expansion of
    instanceof does not check that x is a function. ECMA-262 doesn't
    explicitly define the behaviour if it isn't.

Please review this at http://codereview.appspot.com/124043

Affected files:
  M     tests/com/google/caja/browser-expectations.html


Index: tests/com/google/caja/browser-expectations.html
===================================================================
--- tests/com/google/caja/browser-expectations.html     (revision 3744)
+++ tests/com/google/caja/browser-expectations.html     (working copy)
@@ -37,7 +37,7 @@

     <div id="test-ids-as-targets">
       <iframe style="display:none" id="test-ids-as-targets-1"></iframe>
-      <form target="test-ids-as-targets-1"
+      <form target="test-ids-as-targets-1"
             id="test-ids-as-targets-1-form"
             action="http://www.google.com";></form>
     </div>
@@ -382,6 +382,16 @@
       }
       jsunit.pass();
     });
+
+    jsunitRegister('testInstanceofWoutCtorThrows',
+                   function testInstanceofWoutCtorThrows() {
+      assertThrows(function () { return ({}) instanceof 0; });
+      assertThrows(function () { return ({}) instanceof false; });
+      assertThrows(function () { return ({}) instanceof 'Object'; });
+      assertThrows(function () { return ({}) instanceof {}; });
+      assertThrows(function () { return ({}) instanceof null; });
+      assertThrows(function () { return ({}) instanceof undefined; });
+    });
     </script>

   </body>


Reply via email to