diff --git a/layout/reftests/object/404-data-with-type.html b/layout/reftests/object/404-data-with-type.html index 63afc28621f..5c2c3dd4571 100644 --- a/layout/reftests/object/404-data-with-type.html +++ b/layout/reftests/object/404-data-with-type.html @@ -5,8 +5,6 @@ <object>: 404 data with type -

PASS

+

PASS

diff --git a/layout/reftests/object/404-data.html b/layout/reftests/object/404-data.html index e18ad6966ca..37c7a28a2e3 100644 --- a/layout/reftests/object/404-data.html +++ b/layout/reftests/object/404-data.html @@ -5,8 +5,6 @@ <object>: 404 data -

PASS

+

PASS

diff --git a/layout/reftests/object/extra/404.html b/layout/reftests/object/extra/404.html new file mode 100644 index 00000000000..6c9abdc2c49 --- /dev/null +++ b/layout/reftests/object/extra/404.html @@ -0,0 +1,9 @@ + + + +404 Not Found + + +

This is a 404 page.

+ + diff --git a/layout/reftests/object/extra/404.html^headers^ b/layout/reftests/object/extra/404.html^headers^ new file mode 100644 index 00000000000..937e38c6c45 --- /dev/null +++ b/layout/reftests/object/extra/404.html^headers^ @@ -0,0 +1 @@ +HTTP 404 Not Found diff --git a/layout/reftests/object/reftest.list b/layout/reftests/object/reftest.list index 78444c5af28..0b22c0ffa4b 100644 --- a/layout/reftests/object/reftest.list +++ b/layout/reftests/object/reftest.list @@ -1,6 +1,6 @@ == no-attrs.html no-attrs-ref.html -== 404-data.html 404-data-ref.html -== 404-data-with-type.html 404-data-with-type-ref.html +HTTP == 404-data.html 404-data-ref.html +HTTP == 404-data-with-type.html 404-data-with-type-ref.html == page-as-data.html page-as-data-ref.html == page-as-data-with-type.html page-as-data-with-type-ref.html == connection-refused.html connection-refused-ref.html @@ -9,7 +9,14 @@ == image-no-useful-extension-typesniff.html image-no-useful-extension-typesniff-ref.html == image-no-useful-extension-with-type.html image-no-useful-extension-with-type-ref.html # -# XXX missing tests 011-015 from http://biesi.damowmow.com/object/ here; need +# This test must be run on an HTTP server because it relies on the HTTP +# Content-Type overriding the type specified by the attribute on the object, +# but when run from a local file the type attribute will override the +# content-sniffed assumed type (text/html based entirely on the extension). +# +HTTP == type-overridden-by-server.html type-overridden-by-server-ref.html +# +# XXX missing tests 012-015 from http://biesi.damowmow.com/object/ here; need # a controllable HTTP server (or preferably one run on the test machine) # to add them # diff --git a/layout/reftests/object/type-overridden-by-server-ref.html b/layout/reftests/object/type-overridden-by-server-ref.html new file mode 100644 index 00000000000..6bbbf3c56e5 --- /dev/null +++ b/layout/reftests/object/type-overridden-by-server-ref.html @@ -0,0 +1,10 @@ + + + + +<object>: Server override of type (PNG vs HTML) + + +

+ + diff --git a/layout/reftests/object/type-overridden-by-server.html b/layout/reftests/object/type-overridden-by-server.html new file mode 100644 index 00000000000..dc8a65b8fed --- /dev/null +++ b/layout/reftests/object/type-overridden-by-server.html @@ -0,0 +1,10 @@ + + + + +<object>: Server override of type (PNG vs HTML) + + +

FAIL

+ + diff --git a/layout/tools/reftest/README.txt b/layout/tools/reftest/README.txt index 9e04c29b7af..681d7fb9dff 100644 --- a/layout/tools/reftest/README.txt +++ b/layout/tools/reftest/README.txt @@ -43,7 +43,7 @@ comments) must be one of the following: 2. A test item - * + * [] where @@ -78,17 +78,45 @@ comments) must be one of the following: fails-if(MOZ_WIDGET_TOOLKIT=="cocoa") ... fails-if(MOZ_WIDGET_TOOLKIT=="gtk2") ... - b. is one of the following: + b. , if present, is the string "HTTP" (sans quotes), indicating that + the test should be run over an HTTP server because it requires certain + HTTP headers or a particular HTTP status. (Don't use this if your test + doesn't require this functionality, because it unnecessarily slows down + the test.) + + HTTP tests have the restriction that any resource an HTTP test accesses + must be accessed using a relative URL, and the test and the resource must + be within the directory containing the reftest manifest that describes + the test (or within a descendant directory). + + To modify the HTTP status or headers of a resource named FOO, create a + sibling file named FOO^headers^ with the following contents: + + [] + * + + A line of the form "HTTP ###[ ]", where + ### indicates the desired HTTP status and + indicates a desired HTTP status description, if any. + If this line is omitted, the default is "HTTP 200 OK". + A line in standard HTTP header line format, i.e. + "Field-Name: field-value". You may not repeat the use + of a Field-Name and must coalesce such headers together, + and each header must be specified on a single line, but + otherwise the format exactly matches that from HTTP + itself. + + c. is one of the following: == The test passes if the images of the two renderings are the SAME. != The test passes if the images of the two renderings are DIFFERENT. - c. is either a relative file path or an absolute URL for the + d. is either a relative file path or an absolute URL for the test page - d. is either a relative file path or an absolute URL for + e. is either a relative file path or an absolute URL for the reference page The only difference between and is that results of diff --git a/layout/tools/reftest/reftest.js b/layout/tools/reftest/reftest.js index 57325f84c2c..e1879a0823c 100644 --- a/layout/tools/reftest/reftest.js +++ b/layout/tools/reftest/reftest.js @@ -1,3 +1,4 @@ +/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- / /* vim: set shiftwidth=4 tabstop=8 autoindent cindent expandtab: */ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 @@ -56,12 +57,18 @@ var gURLs; var gState; var gPart1Key; var gFailureTimeout; +var gServer; +var gCount = 0; + +var gIOService; const EXPECTED_PASS = 0; const EXPECTED_FAIL = 1; const EXPECTED_RANDOM = 2; const EXPECTED_DEATH = 3; // test must be skipped to avoid e.g. crash/hang +const HTTP_SERVER_PORT = 4444; + function OnRefTestLoad() { gBrowser = document.getElementById("browser"); @@ -73,8 +80,12 @@ function OnRefTestLoad() gCanvas.setAttribute("width", windowElem.getAttribute("width")); gCanvas.setAttribute("height", windowElem.getAttribute("height")); + gIOService = CC[IO_SERVICE_CONTRACTID].getService(CI.nsIIOService); + try { ReadTopManifest(window.arguments[0]); + if (gServer) + gServer.start(HTTP_SERVER_PORT); StartCurrentTest(); } catch (ex) { gBrowser.loadURI('data:text/plain,' + ex); @@ -89,8 +100,7 @@ function OnRefTestUnload() function ReadTopManifest(aFileURL) { gURLs = new Array(); - var ios = CC[IO_SERVICE_CONTRACTID].getService(CI.nsIIOService); - var url = ios.newURI(aFileURL, null, null); + var url = gIOService.newURI(aFileURL, null, null); if (!url || !url.schemeIs("file")) throw "Expected a file URL for the manifest."; ReadManifest(url); @@ -98,7 +108,6 @@ function ReadTopManifest(aFileURL) function ReadManifest(aURL) { - var ios = CC[IO_SERVICE_CONTRACTID].getService(CI.nsIIOService); var listURL = aURL.QueryInterface(CI.nsIFileURL); var secMan = CC[NS_SCRIPTSECURITYMANAGER_CONTRACTID] @@ -156,32 +165,72 @@ function ReadManifest(aURL) } } + var runHttp = items[0] == "HTTP"; + if (runHttp) + items.shift(); + if (items[0] == "include") { - if (items.length != 2) + if (items.length != 2 || runHttp) throw "Error in manifest file " + aURL.spec + " line " + lineNo; - var incURI = ios.newURI(items[1], null, listURL); + var incURI = gIOService.newURI(items[1], null, listURL); secMan.checkLoadURI(aURL, incURI, CI.nsIScriptSecurityManager.DISALLOW_SCRIPT); ReadManifest(incURI); } else if (items[0] == "==" || items[0] == "!=") { if (items.length != 3) throw "Error in manifest file " + aURL.spec + " line " + lineNo; - var testURI = ios.newURI(items[1], null, listURL); - var refURI = ios.newURI(items[2], null, listURL); + var [testURI, refURI] = runHttp + ? ServeFiles(aURL, + listURL.file.parent, items[1], items[2]) + : [gIOService.newURI(items[1], null, listURL), + gIOService.newURI(items[2], null, listURL)]; + var prettyPath = runHttp + ? gIOService.newURI(items[1], null, listURL).spec + : testURI.spec; secMan.checkLoadURI(aURL, testURI, CI.nsIScriptSecurityManager.DISALLOW_SCRIPT); secMan.checkLoadURI(aURL, refURI, CI.nsIScriptSecurityManager.DISALLOW_SCRIPT); gURLs.push( { equal: (items[0] == "=="), expected: expected_status, + prettyPath: prettyPath, url1: testURI, - url2: refURI} ); + url2: refURI } ); } else { throw "Error in manifest file " + aURL.spec + " line " + lineNo; } } while (more); } +function ServeFiles(manifestURL, directory, file1, file2) +{ + if (!gServer) + gServer = CC["@mozilla.org/server/jshttp;1"]. + createInstance(CI.nsIHttpServer); + + gCount++; + var path = "/" + gCount + "/"; + gServer.registerDirectory(path, directory); + + var testURI = gIOService.newURI("http://localhost:" + HTTP_SERVER_PORT + + path + file1, + null, null); + var refURI = gIOService.newURI("http://localhost:" + HTTP_SERVER_PORT + + path + file2, + null, null); + + var secMan = CC[NS_SCRIPTSECURITYMANAGER_CONTRACTID] + .getService(CI.nsIScriptSecurityManager); + + // XXX necessary? manifestURL guaranteed to be file, others always HTTP + secMan.checkLoadURI(manifestURL, testURI, + CI.nsIScriptSecurityManager.DISALLOW_SCRIPT); + secMan.checkLoadURI(manifestURL, refURI, + CI.nsIScriptSecurityManager.DISALLOW_SCRIPT); + + return [testURI, refURI]; +} + function StartCurrentTest() { // make sure we don't run tests that are expected to kill the browser @@ -206,6 +255,8 @@ function StartCurrentURI(aState) function DoneTests() { + if (gServer) + gServer.stop(); goQuitApplication(); } @@ -318,7 +369,7 @@ function DocumentLoaded() if (!gURLs[0].equal) { result += "(!=) "; } - result += gURLs[0].url1.spec; // the URL being tested + result += gURLs[0].prettyPath; // the URL being tested dump(result + "\n"); if (!test_passed && expected == EXPECTED_PASS) { dump("REFTEST IMAGE 1 (TEST): " + gPart1Key + "\n"); @@ -330,7 +381,7 @@ function DocumentLoaded() StartCurrentTest(); break; default: - throw "Unexpected state." + throw "Unexpected state."; } } diff --git a/netwerk/test/httpserver/Makefile.in b/netwerk/test/httpserver/Makefile.in index d401841e7c6..95335885d28 100644 --- a/netwerk/test/httpserver/Makefile.in +++ b/netwerk/test/httpserver/Makefile.in @@ -45,6 +45,10 @@ include $(DEPTH)/config/autoconf.mk MODULE = test_necko +EXTRA_COMPONENTS = \ + httpd.js \ + $(NULL) + XPIDLSRCS = \ nsIHttpServer.idl \ $(NULL)