content/xml/document/test/test_bug392338.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/xml/document/test/test_bug392338.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,83 @@
     1.4 +<!DOCTYPE HTML>
     1.5 +<html>
     1.6 +<!--
     1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=392338
     1.8 +-->
     1.9 +<head>
    1.10 +  <title>Test for Bug 392338</title>
    1.11 +  <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
    1.12 +  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
    1.13 +</head>
    1.14 +<body>
    1.15 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=392338">Mozilla Bug 392338</a>
    1.16 +<p id="display"></p>
    1.17 +<div id="content" style="display: none">
    1.18 +  
    1.19 +</div>
    1.20 +<pre id="test">
    1.21 +<script class="testbody" type="text/javascript">
    1.22 +
    1.23 +/** Test for Bug 392338 **/
    1.24 +function obs () {
    1.25 +  SpecialPowers.addObserver(this, "http-on-modify-request", false);
    1.26 +  this.window = window;
    1.27 +}
    1.28 +
    1.29 +obs.prototype = {
    1.30 +  observe: function obs_observe (theSubject, theTopic, theData)
    1.31 +  {
    1.32 +    this.timeToFinish = true;
    1.33 +    try{
    1.34 +      var ir = theSubject.QueryInterface(this.window.SpecialPowers.Ci
    1.35 +                                             .nsIChannel).notificationCallbacks;
    1.36 +      if (!ir) {
    1.37 +        this.timeToFinish = false;
    1.38 +        return;
    1.39 +      }
    1.40 +      this.window.ok(true, "No exception thrown");
    1.41 +
    1.42 +      this.window.is(ir.toString().indexOf(this.window.SpecialPowers.Ci.nsIInterfaceRequestor) != -1,
    1.43 +                     true, "Must be an interface requestor");
    1.44 +
    1.45 +      if (ir instanceof this.window.SpecialPowers.Ci.nsIClassInfo) {
    1.46 +        var count = {};
    1.47 +        var interfaces = ir.
    1.48 +                     QueryInterface(this.window.SpecialPowers.Ci.nsIClassInfo).
    1.49 +                     getInterfaces(count).
    1.50 +                     map(function(id) {
    1.51 +                                return this.window.SpecialPowers.CiByID[id].toString();
    1.52 +                         });
    1.53 +        this.window.isnot(interfaces.indexOf("nsIInterfaceRequestor"), -1,
    1.54 +                          "Must have interface requestor classinfo");
    1.55 +      }
    1.56 +    } catch(ex) {
    1.57 +      this.window.is(true, false, "Exception thrown " + ex);
    1.58 +    } finally {
    1.59 +      if (this.timeToFinish) {
    1.60 +        this.remove();
    1.61 +        this.window.SimpleTest.finish();
    1.62 +        this.window = null;
    1.63 +      }
    1.64 +    }
    1.65 +  },
    1.66 +
    1.67 +  remove: function obs_remove()
    1.68 +  {
    1.69 +    SpecialPowers.removeObserver(this, "http-on-modify-request");
    1.70 +  }
    1.71 +}
    1.72 +
    1.73 +var o;
    1.74 +
    1.75 +SimpleTest.waitForExplicitFinish();
    1.76 +addLoadEvent(function() {
    1.77 +  var doc = document.implementation.createDocument("", "", null);
    1.78 +  o = new obs();
    1.79 +  doc.load(window.location.href);
    1.80 +});
    1.81 +
    1.82 +</script>
    1.83 +</pre>
    1.84 +</body>
    1.85 +</html>
    1.86 +

mercurial