Bug 1220730 - Make test_bug392338 work with e10s. r=bz

This commit is contained in:
Andrew McCreight 2015-11-06 16:03:03 -08:00
parent e7b66e98ba
commit 3664a22fb5
3 changed files with 34 additions and 53 deletions

View File

@ -0,0 +1,22 @@
Components.utils.import("resource://gre/modules/Services.jsm");
var modifyObserver = {
observe: function(subject, topic, data) {
if (topic == 'http-on-modify-request') {
var testOk = false;
try {
// We should be able to QI the request to an nsIChannel, then get
// the notificationCallbacks without throwing an exception.
var ir = subject.QueryInterface(Components.interfaces.nsIChannel).notificationCallbacks;
// The notificationCallbacks should be an nsIInterfaceRequestor.
testOk = ir.toString().indexOf(Components.interfaces.nsIInterfaceRequestor) != -1;
} catch (e) {
}
sendAsyncMessage('modify-request-completed', testOk);
Services.obs.removeObserver(modifyObserver, 'http-on-modify-request');
}
}
};
Services.obs.addObserver(modifyObserver, 'http-on-modify-request', false);

View File

@ -2,13 +2,13 @@
support-files =
file_bug293347.xml
file_bug293347xslt.xml
file_bug392338.js
[test_bug232004.xhtml]
[test_bug293347.html]
[test_bug343870.xhtml]
[test_bug355213.xhtml]
[test_bug392338.html]
skip-if = buildapp == 'b2g' || e10s
[test_bug399502.xhtml]
[test_bug445330.html]
[test_bug691215.html]

View File

@ -12,67 +12,26 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=392338
<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 () {
SpecialPowers.addObserver(this, "http-on-modify-request", false);
this.window = window;
}
obs.prototype = {
observe: function obs_observe (theSubject, theTopic, theData)
{
this.timeToFinish = true;
try{
var ir = theSubject.QueryInterface(this.window.SpecialPowers.Ci
.nsIChannel).notificationCallbacks;
if (!ir) {
this.timeToFinish = false;
return;
}
this.window.ok(true, "No exception thrown");
this.window.is(ir.toString().indexOf(this.window.SpecialPowers.Ci.nsIInterfaceRequestor) != -1,
true, "Must be an interface requestor");
if (ir instanceof this.window.SpecialPowers.Ci.nsIClassInfo) {
var count = {};
var interfaces = ir.
QueryInterface(this.window.SpecialPowers.Ci.nsIClassInfo).
getInterfaces(count).
map(function(id) {
return this.window.SpecialPowers.CiByID[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()
{
SpecialPowers.removeObserver(this, "http-on-modify-request");
}
}
var o;
SimpleTest.waitForExplicitFinish();
addLoadEvent(function() {
var doc = document.implementation.createDocument("", "", null);
o = new obs();
var chromeScriptUrl = SimpleTest.getTestFileURL("file_bug392338.js");
var script = SpecialPowers.loadChromeScript(chromeScriptUrl);
script.addMessageListener('modify-request-completed', function ml(data) {
ok(data, "XMLDocument should have notificationCallbacks");
script.removeMessageListener('modify-request-completed', ml);
SimpleTest.finish();
});
doc.load(window.location.href);
});