summaryrefslogtreecommitdiffstats
path: root/dom/xbl/test/test_bug389322.xhtml
blob: 4b80346bd275aa7ceb52dc05b6e2068bb8a56cd4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<html xmlns="http://www.w3.org/1999/xhtml">
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=389322
-->
<head>
  <title>Test for Bug 389322</title>
  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
  <script>var ctorRan = false;</script>
  <bindings xmlns="http://www.mozilla.org/xbl">
    <binding id="test">
      <implementation>
        <field name="field"><![CDATA[
          (function () {
             try {
               eval("let x = 1;");
               var success = true;
             }
             catch (e) { success = false; }
             XPCNativeWrapper.unwrap(window).report("XBL fields", success)
             return ""
           }())
        ]]></field>
        <property name="property">
          <getter><![CDATA[
             try {
               eval("let x = 1;");
               var success = true;
             }
             catch (e) { success = false; }
             XPCNativeWrapper.unwrap(window).report("XBL property getters", success)
             return 1
           ]]></getter>
          <setter><![CDATA[
            try {
              eval("let x = 1;");
              var success = true
            }
            catch (e) { success = false }
            XPCNativeWrapper.unwrap(window).report("XBL property setters", success)
            return val
          ]]></setter>
        </property>
        <method name="method">
          <body><![CDATA[
            try {
              eval("let x = 1;");
              var success = true;

            }
            catch (e) { success = false; }
            XPCNativeWrapper.unwrap(window).report("XBL methods", success)
          ]]></body>
        </method>
        <constructor><![CDATA[
          this.property += 1
          var x = this.field;
          this.method()
          try {
            eval("let x = 1;");
            var success = true
          }
          catch (e) { success = false }
          var win = XPCNativeWrapper.unwrap(window);
          win.report("XBL constructors", success)
        
          var ev = document.createEvent("Events")
          ev.initEvent("custom", false, false)
          this.dispatchEvent(ev)
          win.ctorRan = true;
        ]]></constructor>
      </implementation>
      <handlers>
        <handler action='
          try {
            eval("let x = 1;");
            var success = true
          }
          catch (e) { success = false }
          report("XBL event handlers", success);
        ' event="custom"/>
      </handlers>
    </binding>
  </bindings>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=389322">Mozilla Bug 389322</a>
<p id="display" style="-moz-binding: url(#test)"></p>
<div id="content" style="display: none">
  
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
<![CDATA[

/** Test for Bug 389322 **/
SimpleTest.waitForExplicitFinish();
addLoadEvent(function() {
  is(ctorRan, true, "Constructor should have run");
});
addLoadEvent(SimpleTest.finish);

function report(testName, success) {
  is(success, true, "JS 1.7 should work in " + testName);
}
]]>
</script>
<script type="text/javascript; version=1.7"><![CDATA[
  try {
    eval("let x = 1;");
    var success = true;
  }
  catch (e) { success = false; }
  report("HTML script tags with explicit version", success)
]]></script>
<script type="text/javascript"><![CDATA[
  try {
    eval("let x = 1;");
    var success = true;
  }
  catch (e) { success = false; }
  is(success, true, "let should work in versionless HTML script tags");
]]></script>
</pre>
</body>
</html>