Bug 450450. Add some debugging output to try to fix random orange in test_loadflags.html.

This commit is contained in:
Timothy Nikkel 2010-05-25 18:40:45 -05:00
Родитель 9cdbd39150
Коммит e558f398cb
3 изменённых файлов: 43 добавлений и 6 удалений

Просмотреть файл

@ -7,11 +7,11 @@
document.cookie = "can=has"; document.cookie = "can=has";
// send a message to our test document, to say we're done loading // send a message to our test document, to say we're done loading
window.opener.postMessage("f_lf_i msg data", "http://mochi.test:8888"); window.opener.postMessage("f_lf_i msg data img", "http://mochi.test:8888");
} }
</script> </script>
</head> </head>
<body> <body onload="window.opener.postMessage('f_lf_i msg data page', 'http://mochi.test:8888');">
<img src="http://example.org/tests/extensions/cookie/test/image1.png" onload="runTest()" /> <img src="http://example.org/tests/extensions/cookie/test/image1.png" onload="runTest()" />
</body> </body>
</html> </html>

Просмотреть файл

@ -10,6 +10,9 @@ var gLoads = 0;
// setupTest() is run from 'onload='. // setupTest() is run from 'onload='.
function setupTest(uri, domain, cookies, loads, headers) { function setupTest(uri, domain, cookies, loads, headers) {
ok(true, "setupTest uri: " + uri + " domain: " + domain + " cookies: " + cookies +
" loads: " + loads + " headers: " + headers);
SimpleTest.waitForExplicitFinish(); SimpleTest.waitForExplicitFinish();
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
@ -53,6 +56,8 @@ function finishTest()
function obs () { function obs () {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
ok(true, "adding observer");
this.window = window; this.window = window;
this.os = Components.classes["@mozilla.org/observer-service;1"] this.os = Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService); .getService(Components.interfaces.nsIObserverService);
@ -65,12 +70,28 @@ obs.prototype = {
this.window.netscape.security this.window.netscape.security
.PrivilegeManager.enablePrivilege("UniversalXPConnect"); .PrivilegeManager.enablePrivilege("UniversalXPConnect");
ok(true, "theSubject " + theSubject);
ok(true, "theTopic " + theTopic);
ok(true, "theData " + theData);
var channel = theSubject.QueryInterface( var channel = theSubject.QueryInterface(
this.window.Components.interfaces.nsIHttpChannel); this.window.Components.interfaces.nsIHttpChannel);
ok(true, "channel " + channel);
try {
ok(true, "channel.URI " + channel.URI);
ok(true, "channel.URI.spec " + channel.URI.spec);
channel.visitRequestHeaders({
visitHeader: function(aHeader, aValue) {
ok(true, aHeader + ": " + aValue);
}});
} catch (err) {
ok(false, "catch error " + err);
}
// Ignore notifications we don't care about (like favicons) // Ignore notifications we don't care about (like favicons)
if (channel.URI.spec.indexOf( if (channel.URI.spec.indexOf(
"http://example.org/tests/extensions/cookie/test/") == -1) { "http://example.org/tests/extensions/cookie/test/") == -1) {
ok(true, "ignoring this one");
return; return;
} }
@ -83,6 +104,8 @@ obs.prototype = {
{ {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
ok(true, "removing observer");
this.os.removeObserver(this, "http-on-modify-request"); this.os.removeObserver(this, "http-on-modify-request");
this.os = null; this.os = null;
this.window = null; this.window = null;
@ -93,8 +116,16 @@ obs.prototype = {
// Count and check loads. // Count and check loads.
function messageReceiver(evt) function messageReceiver(evt)
{ {
is(evt.data, "f_lf_i msg data", "message data received from popup"); ok(evt.data == "f_lf_i msg data img" || evt.data == "f_lf_i msg data page",
if (evt.data != "f_lf_i msg data") { "message data received from popup");
if (evt.data == "f_lf_i msg data img") {
ok(true, "message data received from popup for image");
}
if (evt.data == "f_lf_i msg data page") {
ok(true, "message data received from popup for page");
}
if (evt.data != "f_lf_i msg data img" && evt.data != "f_lf_i msg data page") {
ok(true, "got this message but don't know what it is " + evt.data);
gPopup.close(); gPopup.close();
window.removeEventListener("message", messageReceiver, false); window.removeEventListener("message", messageReceiver, false);
@ -124,8 +155,14 @@ function runTest() {
var cs = Components.classes["@mozilla.org/cookiemanager;1"] var cs = Components.classes["@mozilla.org/cookiemanager;1"]
.getService(Components.interfaces.nsICookieManager); .getService(Components.interfaces.nsICookieManager);
var count = 0; var count = 0;
for(var list = cs.enumerator; list.hasMoreElements(); list.getNext()) var list = cs.enumerator;
while (list.hasMoreElements()) {
var cookie = list.getNext().QueryInterface(Components.interfaces.nsICookie);
ok(true, "cookie: " + cookie);
ok(true, "cookie host " + cookie.host + " path " + cookie.path + " name " + cookie.name +
" value " + cookie.value + " isSecure " + cookie.isSecure + " expires " + cookie.expires);
++count; ++count;
}
is(count, gExpectedCookies, "total number of cookies"); is(count, gExpectedCookies, "total number of cookies");
cs.removeAll(); cs.removeAll();

Просмотреть файл

@ -11,7 +11,7 @@
*1 load: file_loadflags_inner.html. *1 load: file_loadflags_inner.html.
*2 headers: 1 for file_loadflags_inner.html + 1 for image1.png. *2 headers: 1 for file_loadflags_inner.html + 1 for image1.png.
--> -->
<body onload="setupTest('http://example.org/tests/extensions/cookie/test/file_loadflags_inner.html', 'example.org', 5, 1, 2)"> <body onload="setupTest('http://example.org/tests/extensions/cookie/test/file_loadflags_inner.html', 'example.org', 5, 2, 2)">
<p id="display"></p> <p id="display"></p>
<pre id="test"> <pre id="test">
<script class="testbody" type="text/javascript" src="file_testloadflags.js"> <script class="testbody" type="text/javascript" src="file_testloadflags.js">