Extensive debugging instrumentation for bug 536603

This commit is contained in:
Zack Weinberg 2010-01-18 09:03:50 -08:00
Родитель f83e5ab166
Коммит 2cd6aaa3ce
6 изменённых файлов: 121 добавлений и 8 удалений

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

@ -1942,6 +1942,9 @@ CSSLoaderImpl::LoadChildSheet(nsICSSStyleSheet* aParentSheet,
// Houston, we have a loop, blow off this child and pretend this never
// happened
LOG_ERROR((" @import cycle detected, dropping load"));
#ifdef NS_BUILD_REFCNT_LOGGING
printf("@import cycle detected, dropping load");
#endif
return NS_OK;
}
data = data->mParentData;
@ -2247,6 +2250,11 @@ CSSLoaderImpl::Stop()
#endif
}
mPostedEvents.Clear();
#ifdef NS_BUILD_REFCNT_LOGGING
if (arr.Length() != 0) {
printf("nsCSSLoader::Stop: stopping %d loads\n", int(arr.Length()));
}
#endif
mDatasToNotifyOn += arr.Length();
for (i = 0; i < arr.Length(); ++i) {
@ -2330,6 +2338,11 @@ CSSLoaderImpl::StopLoadingSheet(nsIURI* aURL)
}
mPostedEvents.Clear();
#ifdef NS_BUILD_REFCNT_LOGGING
if (arr.Length() != 0) {
printf("nsCSSLoader::StopLoadingSheet: stopping %d loads\n", int(arr.Length()));
}
#endif
mDatasToNotifyOn += arr.Length();
for (i = 0; i < arr.Length(); ++i) {
--mDatasToNotifyOn;

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

@ -3,6 +3,8 @@ const DEBUG_all_stub = false;
function handleRequest(request, response)
{
dump("ccd.sjs: handling request with query " + request.queryString + "\n");
// Decode the query string to know what test we're doing.
// character 1: 'I' = text/css response, 'J' = text/html response

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

@ -1,5 +1,6 @@
function handleRequest(request, response)
{
dump("redirect.sjs: handling request with query " + request.queryString + "\n");
response.setStatusLine(request.httpVersion, 301, "Moved Permanently");
response.setHeader("Location", request.queryString, false);
}

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

@ -36,6 +36,8 @@
<hr/>
<iframe src="/server/debug?2" style="width: 100%; height: 30px"></iframe>
<div class="column">
<h2>&nbsp;</h2>
<ol><li>text/css<ol><li>same origin<ol><li>valid</li>
@ -80,6 +82,46 @@
/** Test for Bug 524223 **/
function check_iframe(ifr) {
var doc = ifr.contentDocument;
// To debug bug 536603, check the imported style rules in the iframe.
netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserWrite');
var parentSheet = doc.getElementsByTagName("style")[1].sheet;
for (var idx = 0; idx < parentSheet.cssRules.length; ++idx) {
var rule = parentSheet.cssRules[idx];
var ch = rule.href.indexOf("ccd.sjs?");
var id = rule.href.substring(ch + 8).substring(0,4);
if (rule.styleSheet) {
var rl = rule.styleSheet.cssRules;
if (rl.length > 0) {
var lastRule = rl[rl.length - 1];
is(lastRule.selectorText, "#" + id,
"selector text for rule @import-ed at " + rule.href + " that specifies color " + lastRule.style.backgroundColor);
} else {
ok(true, "@import rule importing " + rule.href + " has no rules");
}
} else {
ok(true, "@import rule importing " + rule.href + " has no sheet");
}
}
var links = doc.getElementsByTagName("link");
for (idx = 0; idx < links.length; ++idx) {
var link = links[idx];
var ch = link.href.indexOf("ccd.sjs?");
var id = link.href.substring(ch + 8).substring(0,4);
if (link.sheet) {
var rl = link.sheet.cssRules;
if (rl.length > 0) {
var lastRule = rl[rl.length - 1];
is(lastRule.selectorText, "#" + id,
"selector text for rule <link>ed at " + link.href + " that specifies color " + lastRule.style.backgroundColor);
} else {
ok(true, "<link>ed rule at " + link.href + " has no rules");
}
} else {
ok(true, "<link>ed rule at " + link.href + " has no sheet");
}
}
var cases = doc.getElementsByTagName("p");
for (var i = 0; i < cases.length; i++) {
var color = doc.defaultView.getComputedStyle(cases[i], "")
@ -91,13 +133,18 @@ function check_iframe(ifr) {
SimpleTest.waitForExplicitFinish();
window.onload = function() {
// The quirks-mode tests are inexplicably failing intermittently
// on Mac (bug 536603), so disable them for now.
if (navigator.platform.substring(0,3) != "Mac")
check_iframe(document.getElementById("quirks"));
check_iframe(document.getElementById("quirks"));
check_iframe(document.getElementById("standards"));
SimpleTest.finish();
setTimeout(function() {
check_iframe(document.getElementById("quirks"));
check_iframe(document.getElementById("standards"));
document.getElementById("debugOff").
setAttribute("src", "/server/debug?0");
SimpleTest.finish();
}, 5000);
};
</script>
<iframe id="debugOff" style="width: 100%; height: 30px"></iframe>
</body>
</html>

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

@ -57,6 +57,9 @@ const PR_UINT32_MAX = Math.pow(2, 32) - 1;
/** True if debugging output is enabled, false otherwise. */
var DEBUG = false; // non-const *only* so tweakable in server tests
/** True if debugging output should be timestamped. */
var DEBUG_TIMESTAMP = false; // non-const so tweakable in server tests
var gGlobalObject = this;
/**
@ -75,7 +78,7 @@ function NS_ASSERT(cond, msg)
var stack = new Error().stack.split(/\n/);
dumpn(stack.map(function(val) { return "###!!! " + val; }).join("\n"));
throw Cr.NS_ERROR_ABORT;
}
}
@ -166,10 +169,26 @@ const SJS_TYPE = "sjs";
/** dump(str) with a trailing "\n" -- only outputs if DEBUG */
var first_stamp = null;
function dumpn(str)
{
if (DEBUG)
dump(str + "\n");
if (DEBUG) {
var prefix = "|HTTPD|";
if (DEBUG_TIMESTAMP) {
if (first_stamp === null) {
first_stamp = new Date();
}
var elapsed = (new Date() - first_stamp)/1000; // in decimal seconds
var min = Math.floor(elapsed/60);
var sec = elapsed - 60*min;
if (sec < 10)
prefix += min + ":0" + sec.toFixed(3) + " ";
else
prefix += min + ":" + sec.toFixed(3) + " ";
}
dump(prefix + str + "\n");
}
}
/** Dumps the current JS stack if DEBUG. */

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

@ -198,6 +198,7 @@ function createMochitestServer(serverBasePath)
server.registerDirectory("/", serverBasePath);
server.registerPathHandler("/server/shutdown", serverShutdown);
server.registerPathHandler("/server/debug", serverDebug);
server.registerContentType("sjs", "sjs"); // .sjs == CGI-like functionality
server.registerContentType("jar", "application/x-jar");
server.registerContentType("ogg", "application/ogg");
@ -297,6 +298,36 @@ function serverShutdown(metadata, response)
server.stop(serverStopped);
}
// /server/debug?[012]
function serverDebug(metadata, response)
{
var mode;
if (metadata.queryString.length != 1) {
throw HTTP_400;
} else if (metadata.queryString[0] == '0') {
// do this now so it gets logged with the old mode
dumpn("Server debug logs disabled.");
DEBUG = false;
DEBUG_TIMESTAMP = false;
mode = "disabled";
} else if (metadata.queryString[0] == '1') {
DEBUG = true;
DEBUG_TIMESTAMP = false;
mode = "enabled";
} else if (metadata.queryString[0] == '2') {
DEBUG = true;
DEBUG_TIMESTAMP = true;
mode = "enabled, with timestamps";
} else {
throw HTTP_400;
}
response.setStatusLine("1.1", 200, "OK");
response.setHeader("Content-type", "text/plain", false);
var body = "Server debug logs " + mode + ".";
response.bodyOutputStream.write(body, body.length);
dumpn(body);
}
//
// DIRECTORY LISTINGS
//