gecko/content/xml/document/test/test_bug392338.html

95 lines
3.0 KiB
HTML

<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=392338
-->
<head>
<title>Test for Bug 392338</title>
<script type="text/javascript" src="/MochiKit/MochiKit.js"></script>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=392338">Mozilla Bug 392338</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
<script class="testbody" type="text/javascript">
/** Test for Bug 392338 **/
function obs () {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
this.observerService = Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService);
this.observerService.addObserver(this,"http-on-modify-request", false);
this.window = window;
}
obs.prototype = {
observe: function obs_observe (theSubject, theTopic, theData)
{
this.timeToFinish = true;
try{
this.window.netscape.security
.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var ir = theSubject.QueryInterface(this.window.Components.interfaces
.nsIChannel).notificationCallbacks;
if (!ir) {
this.timeToFinish = false;
return;
}
this.window.ok(true, "No exception thrown");
this.window.is(ir instanceof
this.window.Components.interfaces.nsIInterfaceRequestor,
true, "Must be an interface requestor");
if (ir instanceof this.window.Components.interfaces.nsIClassInfo) {
var count = {};
var interfaces = ir.
QueryInterface(this.window.Components
.interfaces.nsIClassInfo).
getInterfaces(count).
map(function(id) {
return this.window.Components
.interfacesByID[id].toString();
});
this.window.isnot(interfaces.indexOf("nsIInterfaceRequestor"), -1,
"Must have interface requestor classinfo");
}
} catch(ex) {
this.window.is(true, false, "Exception thrown " + ex);
} finally {
if (this.timeToFinish) {
this.remove();
this.window.SimpleTest.finish();
this.window = null;
}
}
},
remove: function obs_remove()
{
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
this.observerService.removeObserver(this,"http-on-modify-request");
this.observerService = null;
}
}
var o;
SimpleTest.waitForExplicitFinish();
addLoadEvent(function() {
var doc = document.implementation.createDocument("", "", null);
o = new obs();
doc.load(window.location.href);
});
</script>
</pre>
</body>
</html>