dom/xbl/test/test_bug389322.xhtml

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     1 <html xmlns="http://www.w3.org/1999/xhtml">
     2 <!--
     3 https://bugzilla.mozilla.org/show_bug.cgi?id=389322
     4 -->
     5 <head>
     6   <title>Test for Bug 389322</title>
     7   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     8   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
     9   <script>var ctorRan = false;</script>
    10   <bindings xmlns="http://www.mozilla.org/xbl">
    11     <binding id="test">
    12       <implementation>
    13         <field name="field"><![CDATA[
    14           (function () {
    15              try {
    16                let (x=1) (x);
    17                var success = true;
    18              }
    19              catch (e) { success = false; }
    20              XPCNativeWrapper.unwrap(window).report("XBL fields", success)
    21              return ""
    22            }())
    23         ]]></field>
    24         <property name="property">
    25           <getter><![CDATA[
    26              try {
    27                let (x=1) (x);
    28                var success = true;
    29              }
    30              catch (e) { success = false; }
    31              XPCNativeWrapper.unwrap(window).report("XBL property getters", success)
    32              return 1
    33            ]]></getter>
    34           <setter><![CDATA[
    35             try {
    36               let (x=1) (x);
    37               var success = true
    38             }
    39             catch (e) { success = false }
    40             XPCNativeWrapper.unwrap(window).report("XBL property setters", success)
    41             return val
    42           ]]></setter>
    43         </property>
    44         <method name="method">
    45           <body><![CDATA[
    46             try {
    47               let (x=1) (x);
    48               var success = true;
    49             }
    50             catch (e) { success = false; }
    51             XPCNativeWrapper.unwrap(window).report("XBL methods", success)
    52           ]]></body>
    53         </method>
    54         <constructor><![CDATA[
    55           this.property += 1
    56           var x = this.field;
    57           this.method()
    58           try {
    59             let (x=1) (x);
    60             var success = true
    61           }
    62           catch (e) { success = false }
    63           var win = XPCNativeWrapper.unwrap(window);
    64           win.report("XBL constructors", success)
    66           var ev = document.createEvent("Events")
    67           ev.initEvent("custom", false, false)
    68           this.dispatchEvent(ev)
    69           win.ctorRan = true;
    70         ]]></constructor>
    71       </implementation>
    72       <handlers>
    73         <handler action='
    74           try {
    75             let (x=1) (x);
    76             var success = true
    77           }
    78           catch (e) { success = false }
    79           report("XBL event handlers", success);
    80         ' event="custom"/>
    81       </handlers>
    82     </binding>
    83   </bindings>
    84 </head>
    85 <body>
    86 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=389322">Mozilla Bug 389322</a>
    87 <p id="display" style="-moz-binding: url(#test)"></p>
    88 <div id="content" style="display: none">
    90 </div>
    91 <pre id="test">
    92 <script class="testbody" type="text/javascript">
    93 <![CDATA[
    95 /** Test for Bug 389322 **/
    96 SimpleTest.waitForExplicitFinish();
    97 addLoadEvent(function() {
    98   is(ctorRan, true, "Constructor should have run");
    99 });
   100 addLoadEvent(SimpleTest.finish);
   102 function report(testName, success) {
   103   is(success, true, "JS 1.7 should work in " + testName);
   104 }
   105 ]]>
   106 </script>
   107 <script type="text/javascript; version=1.7"><![CDATA[
   108   try {
   109     let (x=1) (x);
   110     var success = true;
   111   }
   112   catch (e) { success = false; }
   113   report("HTML script tags with explicit version", success)
   114 ]]></script>
   115 <script type="text/javascript"><![CDATA[
   116   try {
   117     let (x=1) (x);
   118     var success = false;
   119   }
   120   catch (e) { success = true; }
   121   is(success, true, "JS 1.7 should not work in versionless HTML script tags");
   122 ]]></script>
   123 </pre>
   124 </body>
   125 </html>

mercurial