PageRenderTime 29ms CodeModel.GetById 19ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/js/jsd/test/test_bug507448.html

http://github.com/zpao/v8monkey
HTML | 112 lines | 97 code | 12 blank | 3 comment | 0 complexity | b476a237b3551296bce348484091809d MD5 | raw file
  1<!DOCTYPE HTML>
  2<html>
  3<!--
  4https://bugzilla.mozilla.org/show_bug.cgi?id=507448
  5-->
  6<head>
  7  <title>Test for Bug 507448</title>
  8  <script type="application/javascript" src="/MochiKit/Base.js"></script>
  9  <script type="application/javascript" src="/MochiKit/Async.js"></script>
 10  <script type="application/javascript" src="/MochiKit/DOM.js"></script>
 11  <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
 12  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
 13</head>
 14<body>
 15<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=507448">Mozilla Bug 507448</a>
 16<p id="display"></p>
 17<div id="content" style="display: none">
 18  
 19</div>
 20<pre id="test">
 21<script type="application/javascript">
 22function f() {}
 23function g(a,b) {}
 24function h(me, too, here) { var x = 1; }
 25function annoying(a, b, a, b, b, a) {}
 26function manyLocals(a, b, c, d, e, f, g, h, i, j, k, l, m) {
 27  var n, o, p, q, r, s, t, u, v, w, x, y, z;
 28}
 29</script>
 30<script type="application/javascript">
 31
 32SimpleTest.waitForExplicitFinish();
 33
 34function loadScript(url) {
 35    var d = new MochiKit.Async.Deferred();
 36    var head = document.getElementsByTagName("head")[0];
 37    var script = MochiKit.DOM.createDOM("script", { type: "text/javascript", src: url });
 38    script.onload = function() {
 39        script.onload = null;
 40        script.onerror = null;
 41        script.onreadystatechange = null;
 42        d.callback();
 43    };
 44    script.onerror = function(msg) {
 45        script.onload = null;
 46        script.onerror = null;
 47        script.onreadystatechange = null;
 48        msg = "Failed to load script at " + url + ": " + msg;
 49        d.errback(new URIError(msg, url));
 50    }
 51    script.onreadystatechange = function() {
 52        if (script.readyState == "loaded" || script.readyState == "complete") {
 53            script.onload();
 54        } else {
 55            // IE doesn't bother to report errors...
 56            MochiKit.Async.callLater(10, script.onerror, "Script loading timed out")
 57        }
 58    };
 59    head.appendChild(script);
 60    return d;
 61}
 62
 63/** Test for Bug 507448 **/
 64function assertArraysEqual(arr1, arr2) {
 65  is(arr1.length, arr2.length, "Lengths not equal");
 66  for (var i = 0 ; i < arr1.length; ++i) {
 67    is(arr1[i], arr2[i], "Element " + i + " not equal");
 68  }
 69}
 70
 71netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
 72var jsdIDebuggerService = Components.interfaces.jsdIDebuggerService;
 73var jsd = Components.classes['@mozilla.org/js/jsd/debugger-service;1']
 74                    .getService(jsdIDebuggerService);
 75var jsdOnAtStart = false;
 76
 77function setupJSD() {
 78  // This is somewhat unfortunate: jsd only deals with scripts that have a
 79  // nonzero line number, so we can't just createElement a script here.
 80  // So break the test up into three <script>s, of which the middle one has our test functions.
 81
 82  netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
 83
 84  jsdOnAtStart = jsd.isOn;
 85  if (jsdOnAtStart) {
 86    testJSD();
 87  } else {
 88    jsd.asyncOn(
 89      {
 90        onDebuggerActivated: function() {
 91            testJSD();
 92        }
 93      }  
 94    );
 95  }
 96}
 97
 98addLoadEvent(setupJSD);
 99
100</script>
101<script>
102function testJSD() {
103  netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
104
105  ok(jsd.isOn, "JSD needs to be running for this test.");
106
107  var deferred = loadScript("bug507448.js");
108}
109</script>
110</pre>
111</body>
112</html>