2007-07-18 14:32:50 -07:00
|
|
|
/* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- /
|
2007-03-22 10:30:00 -07:00
|
|
|
/* vim: set shiftwidth=4 tabstop=8 autoindent cindent expandtab: */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is Mozilla's layout acceptance tests.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is the Mozilla Foundation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2006
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
* L. David Baron <dbaron@dbaron.org>, Mozilla Corporation (original author)
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
|
|
|
const CC = Components.classes;
|
|
|
|
const CI = Components.interfaces;
|
|
|
|
const CR = Components.results;
|
|
|
|
|
|
|
|
const XHTML_NS = "http://www.w3.org/1999/xhtml";
|
|
|
|
|
|
|
|
const NS_LOCAL_FILE_CONTRACTID = "@mozilla.org/file/local;1";
|
|
|
|
const IO_SERVICE_CONTRACTID = "@mozilla.org/network/io-service;1";
|
2009-01-08 13:50:21 -08:00
|
|
|
const DEBUG_CONTRACTID = "@mozilla.org/xpcom/debug;1";
|
2007-03-22 10:30:00 -07:00
|
|
|
const NS_LOCALFILEINPUTSTREAM_CONTRACTID =
|
|
|
|
"@mozilla.org/network/file-input-stream;1";
|
2007-06-12 11:25:15 -07:00
|
|
|
const NS_SCRIPTSECURITYMANAGER_CONTRACTID =
|
|
|
|
"@mozilla.org/scriptsecuritymanager;1";
|
2007-08-02 19:28:55 -07:00
|
|
|
const NS_REFTESTHELPER_CONTRACTID =
|
|
|
|
"@mozilla.org/reftest-helper;1";
|
2008-08-06 15:38:44 -07:00
|
|
|
const NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX =
|
|
|
|
"@mozilla.org/network/protocol;1?name=";
|
2009-02-03 06:11:28 -08:00
|
|
|
const NS_XREAPPINFO_CONTRACTID =
|
|
|
|
"@mozilla.org/xre/app-info;1";
|
|
|
|
|
2009-06-19 11:17:55 -07:00
|
|
|
var gLoadTimeout = 0;
|
2010-03-12 14:31:53 -08:00
|
|
|
var gRemote = false;
|
2010-03-29 10:57:51 -07:00
|
|
|
var gTotalChunks = 0;
|
|
|
|
var gThisChunk = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-02-10 14:05:27 -08:00
|
|
|
// "<!--CLEAR-->"
|
|
|
|
const BLANK_URL_FOR_CLEARING = "data:text/html,%3C%21%2D%2DCLEAR%2D%2D%3E";
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
var gBrowser;
|
2008-12-16 18:15:38 -08:00
|
|
|
var gCanvas1, gCanvas2;
|
2009-01-05 17:15:13 -08:00
|
|
|
// gCurrentCanvas is non-null between InitCurrentCanvasWithSnapshot and the next
|
|
|
|
// DocumentLoaded.
|
|
|
|
var gCurrentCanvas = null;
|
2007-03-22 10:30:00 -07:00
|
|
|
var gURLs;
|
2008-12-07 16:48:36 -08:00
|
|
|
// Map from URI spec to the number of times it remains to be used
|
|
|
|
var gURIUseCounts;
|
|
|
|
// Map from URI spec to the canvas rendered for that URI
|
|
|
|
var gURICanvases;
|
2008-12-02 04:35:24 -08:00
|
|
|
var gTestResults = {
|
2008-12-11 15:48:32 -08:00
|
|
|
// Successful...
|
|
|
|
Pass: 0,
|
|
|
|
LoadOnly: 0,
|
|
|
|
// Unexpected...
|
2008-12-02 04:35:24 -08:00
|
|
|
Exception: 0,
|
|
|
|
FailedLoad: 0,
|
|
|
|
UnexpectedFail: 0,
|
|
|
|
UnexpectedPass: 0,
|
2009-01-08 13:50:21 -08:00
|
|
|
AssertionUnexpected: 0,
|
|
|
|
AssertionUnexpectedFixed: 0,
|
2008-12-11 15:48:32 -08:00
|
|
|
// Known problems...
|
2008-12-02 04:35:24 -08:00
|
|
|
KnownFail : 0,
|
2009-01-08 13:50:21 -08:00
|
|
|
AssertionKnown: 0,
|
2008-12-02 04:35:24 -08:00
|
|
|
Random : 0,
|
|
|
|
Skip: 0,
|
|
|
|
};
|
2008-07-19 13:54:47 -07:00
|
|
|
var gTotalTests = 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
var gState;
|
2008-10-19 13:27:46 -07:00
|
|
|
var gCurrentURL;
|
2009-02-08 10:28:30 -08:00
|
|
|
var gFailureTimeout = null;
|
2008-10-19 13:27:46 -07:00
|
|
|
var gFailureReason;
|
2007-07-18 14:32:50 -07:00
|
|
|
var gServer;
|
|
|
|
var gCount = 0;
|
2009-01-08 13:50:21 -08:00
|
|
|
var gAssertionCount = 0;
|
2007-07-18 14:32:50 -07:00
|
|
|
|
|
|
|
var gIOService;
|
2009-01-08 13:50:21 -08:00
|
|
|
var gDebug;
|
2008-12-02 17:34:07 -08:00
|
|
|
var gWindowUtils;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-04-29 17:39:45 -07:00
|
|
|
var gCurrentTestStartTime;
|
|
|
|
var gSlowestTestTime = 0;
|
|
|
|
var gSlowestTestURL;
|
2009-01-08 13:50:21 -08:00
|
|
|
var gClearingForAssertionCheck = false;
|
2008-04-29 17:39:45 -07:00
|
|
|
|
2009-08-20 00:56:22 -07:00
|
|
|
const TYPE_REFTEST_EQUAL = '==';
|
|
|
|
const TYPE_REFTEST_NOTEQUAL = '!=';
|
|
|
|
const TYPE_LOAD = 'load'; // test without a reference (just test that it does
|
|
|
|
// not assert, crash, hang, or leak)
|
|
|
|
const TYPE_SCRIPT = 'script'; // test contains individual test results
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
const EXPECTED_PASS = 0;
|
|
|
|
const EXPECTED_FAIL = 1;
|
|
|
|
const EXPECTED_RANDOM = 2;
|
2007-05-08 03:21:22 -07:00
|
|
|
const EXPECTED_DEATH = 3; // test must be skipped to avoid e.g. crash/hang
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-09-26 15:54:12 -07:00
|
|
|
const gProtocolRE = /^\w+:/;
|
|
|
|
|
2009-02-06 08:52:13 -08:00
|
|
|
var HTTP_SERVER_PORT = 4444;
|
|
|
|
const HTTP_SERVER_PORTS_TO_TRY = 50;
|
2007-07-18 14:32:50 -07:00
|
|
|
|
2009-09-22 13:01:11 -07:00
|
|
|
// whether we should skip caching canvases
|
|
|
|
var gNoCanvasCache = false;
|
|
|
|
|
2008-12-07 16:48:36 -08:00
|
|
|
var gRecycledCanvases = new Array();
|
|
|
|
|
|
|
|
function AllocateCanvas()
|
|
|
|
{
|
|
|
|
var windowElem = document.documentElement;
|
|
|
|
|
|
|
|
if (gRecycledCanvases.length > 0)
|
|
|
|
return gRecycledCanvases.shift();
|
|
|
|
|
|
|
|
var canvas = document.createElementNS(XHTML_NS, "canvas");
|
|
|
|
canvas.setAttribute("width", windowElem.getAttribute("width"));
|
|
|
|
canvas.setAttribute("height", windowElem.getAttribute("height"));
|
2009-09-22 13:01:11 -07:00
|
|
|
|
2008-12-07 16:48:36 -08:00
|
|
|
return canvas;
|
|
|
|
}
|
|
|
|
|
|
|
|
function ReleaseCanvas(canvas)
|
|
|
|
{
|
2009-09-22 13:01:11 -07:00
|
|
|
// store a maximum of 2 canvases, if we're not caching
|
|
|
|
if (!gNoCanvasCache || gRecycledCanvases.length < 2)
|
|
|
|
gRecycledCanvases.push(canvas);
|
2008-12-07 16:48:36 -08:00
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
function OnRefTestLoad()
|
|
|
|
{
|
|
|
|
gBrowser = document.getElementById("browser");
|
|
|
|
|
2009-06-19 11:17:55 -07:00
|
|
|
/* set the gLoadTimeout */
|
|
|
|
try {
|
|
|
|
var prefs = Components.classes["@mozilla.org/preferences-service;1"].
|
|
|
|
getService(Components.interfaces.nsIPrefBranch2);
|
|
|
|
gLoadTimeout = prefs.getIntPref("reftest.timeout");
|
2010-03-12 14:31:53 -08:00
|
|
|
gRemote = prefs.getBoolPref("reftest.remote");
|
2009-08-20 00:56:22 -07:00
|
|
|
}
|
2009-06-19 11:17:55 -07:00
|
|
|
catch(e) {
|
|
|
|
gLoadTimeout = 5 * 60 * 1000; //5 minutes as per bug 479518
|
|
|
|
}
|
|
|
|
|
2010-03-29 10:57:51 -07:00
|
|
|
|
2010-04-08 21:03:47 -07:00
|
|
|
/* Support for running a chunk (subset) of tests. In separate try as this is optional */
|
2010-03-29 10:57:51 -07:00
|
|
|
try {
|
|
|
|
gTotalChunks = prefs.getIntPref("reftest.totalChunks");
|
|
|
|
gThisChunk = prefs.getIntPref("reftest.thisChunk");
|
|
|
|
}
|
|
|
|
catch(e) {
|
|
|
|
gTotalChunks = 0;
|
|
|
|
gThisChunk = 0;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
gBrowser.addEventListener("load", OnDocumentLoad, true);
|
|
|
|
|
2008-12-02 17:34:07 -08:00
|
|
|
try {
|
|
|
|
gWindowUtils = window.QueryInterface(CI.nsIInterfaceRequestor).getInterface(CI.nsIDOMWindowUtils);
|
|
|
|
if (gWindowUtils && !gWindowUtils.compareCanvases)
|
|
|
|
gWindowUtils = null;
|
2007-08-02 19:28:55 -07:00
|
|
|
} catch (e) {
|
2008-12-02 17:34:07 -08:00
|
|
|
gWindowUtils = null;
|
2007-08-02 19:28:55 -07:00
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
var windowElem = document.documentElement;
|
2007-08-02 19:28:55 -07:00
|
|
|
|
2007-07-18 14:32:50 -07:00
|
|
|
gIOService = CC[IO_SERVICE_CONTRACTID].getService(CI.nsIIOService);
|
2009-01-08 13:50:21 -08:00
|
|
|
gDebug = CC[DEBUG_CONTRACTID].getService(CI.nsIDebug2);
|
2010-03-12 14:31:53 -08:00
|
|
|
|
|
|
|
if (gRemote) {
|
|
|
|
gServer = null;
|
|
|
|
} else {
|
|
|
|
gServer = CC["@mozilla.org/server/jshttp;1"].
|
|
|
|
createInstance(CI.nsIHttpServer);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
try {
|
2009-04-15 13:19:35 -07:00
|
|
|
if (gServer)
|
|
|
|
StartHTTPServer();
|
|
|
|
} catch (ex) {
|
|
|
|
//gBrowser.loadURI('data:text/plain,' + ex);
|
|
|
|
++gTestResults.Exception;
|
|
|
|
dump("REFTEST TEST-UNEXPECTED-FAIL | | EXCEPTION: " + ex + "\n");
|
|
|
|
DoneTests();
|
|
|
|
}
|
|
|
|
|
2010-03-27 08:16:53 -07:00
|
|
|
// Focus the content browser
|
|
|
|
gBrowser.focus();
|
|
|
|
|
2009-04-15 13:19:35 -07:00
|
|
|
StartTests();
|
|
|
|
}
|
|
|
|
|
|
|
|
function StartHTTPServer()
|
|
|
|
{
|
|
|
|
gServer.registerContentType("sjs", "sjs");
|
|
|
|
// We want to try different ports in case the port we want
|
|
|
|
// is being used.
|
|
|
|
var tries = HTTP_SERVER_PORTS_TO_TRY;
|
|
|
|
do {
|
|
|
|
try {
|
|
|
|
gServer.start(HTTP_SERVER_PORT);
|
|
|
|
return;
|
|
|
|
} catch (ex) {
|
|
|
|
++HTTP_SERVER_PORT;
|
|
|
|
if (--tries == 0)
|
|
|
|
throw ex;
|
2008-02-11 12:32:40 -08:00
|
|
|
}
|
2009-04-15 13:19:35 -07:00
|
|
|
} while (true);
|
|
|
|
}
|
|
|
|
|
|
|
|
function StartTests()
|
|
|
|
{
|
|
|
|
try {
|
2009-02-06 08:52:13 -08:00
|
|
|
// Need to read the manifest once we have the final HTTP_SERVER_PORT.
|
2009-10-03 01:26:38 -07:00
|
|
|
var args = window.arguments[0].wrappedJSObject;
|
2009-09-22 13:01:11 -07:00
|
|
|
|
|
|
|
if ("nocache" in args && args["nocache"])
|
|
|
|
gNoCanvasCache = true;
|
|
|
|
|
|
|
|
ReadTopManifest(args.uri);
|
2009-02-06 08:52:13 -08:00
|
|
|
BuildUseCounts();
|
2010-03-29 10:57:51 -07:00
|
|
|
|
|
|
|
if (gTotalChunks > 0 && gThisChunk > 0) {
|
|
|
|
var testsPerChunk = gURLs.length / gTotalChunks;
|
|
|
|
var start = Math.round((gThisChunk-1) * testsPerChunk);
|
|
|
|
var end = Math.round(gThisChunk * testsPerChunk);
|
|
|
|
gURLs = gURLs.slice(start, end);
|
|
|
|
dump("REFTEST INFO | Running chunk " + gThisChunk + " out of " + gTotalChunks + " chunks. ")
|
|
|
|
dump("tests " + (start+1) + "-" + end + "/" + gURLs.length + "\n");
|
|
|
|
}
|
2008-07-19 13:54:47 -07:00
|
|
|
gTotalTests = gURLs.length;
|
2009-05-14 07:17:45 -07:00
|
|
|
|
|
|
|
if (!gTotalTests)
|
|
|
|
throw "No tests to run";
|
|
|
|
|
2008-12-07 16:48:36 -08:00
|
|
|
gURICanvases = {};
|
2007-03-22 10:30:00 -07:00
|
|
|
StartCurrentTest();
|
|
|
|
} catch (ex) {
|
2007-08-02 01:53:53 -07:00
|
|
|
//gBrowser.loadURI('data:text/plain,' + ex);
|
2008-12-02 04:35:24 -08:00
|
|
|
++gTestResults.Exception;
|
2008-12-08 14:03:49 -08:00
|
|
|
dump("REFTEST TEST-UNEXPECTED-FAIL | | EXCEPTION: " + ex + "\n");
|
2007-08-02 01:53:53 -07:00
|
|
|
DoneTests();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function OnRefTestUnload()
|
|
|
|
{
|
2008-09-08 14:47:26 -07:00
|
|
|
/* Clear the sRGB forcing pref to leave the profile as we found it. */
|
|
|
|
var prefs = Components.classes["@mozilla.org/preferences-service;1"].
|
|
|
|
getService(Components.interfaces.nsIPrefBranch2);
|
|
|
|
prefs.clearUserPref("gfx.color_management.force_srgb");
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
gBrowser.removeEventListener("load", OnDocumentLoad, true);
|
|
|
|
}
|
|
|
|
|
2010-03-12 14:31:53 -08:00
|
|
|
// Read all available data from an input stream and return it
|
|
|
|
// as a string.
|
|
|
|
function getStreamContent(inputStream)
|
|
|
|
{
|
|
|
|
var streamBuf = "";
|
|
|
|
var sis = CC["@mozilla.org/scriptableinputstream;1"].
|
|
|
|
createInstance(CI.nsIScriptableInputStream);
|
|
|
|
sis.init(inputStream);
|
|
|
|
|
|
|
|
var available;
|
|
|
|
while ((available = sis.available()) != 0) {
|
|
|
|
streamBuf += sis.read(available);
|
|
|
|
}
|
|
|
|
|
|
|
|
return streamBuf;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
function ReadTopManifest(aFileURL)
|
|
|
|
{
|
|
|
|
gURLs = new Array();
|
2007-07-18 14:32:50 -07:00
|
|
|
var url = gIOService.newURI(aFileURL, null, null);
|
2010-03-12 14:31:53 -08:00
|
|
|
if (!url)
|
|
|
|
throw "Expected a file or http URL for the manifest.";
|
2007-03-22 10:30:00 -07:00
|
|
|
ReadManifest(url);
|
|
|
|
}
|
|
|
|
|
2009-03-11 08:56:58 -07:00
|
|
|
// Note: If you materially change the reftest manifest parsing,
|
|
|
|
// please keep the parser in print-manifest-dirs.py in sync.
|
2007-03-22 10:30:00 -07:00
|
|
|
function ReadManifest(aURL)
|
|
|
|
{
|
2007-06-12 11:25:15 -07:00
|
|
|
var secMan = CC[NS_SCRIPTSECURITYMANAGER_CONTRACTID]
|
|
|
|
.getService(CI.nsIScriptSecurityManager);
|
|
|
|
|
2010-03-12 14:31:53 -08:00
|
|
|
var listURL = aURL;
|
|
|
|
var channel = gIOService.newChannelFromURI(aURL);
|
|
|
|
var inputStream = channel.open();
|
|
|
|
if (channel instanceof Components.interfaces.nsIHttpChannel
|
|
|
|
&& channel.responseStatus != 200) {
|
|
|
|
dump("REFTEST TEST-UNEXPECTED-FAIL | | HTTP ERROR : " +
|
|
|
|
channel.responseStatus + "\n");
|
|
|
|
}
|
|
|
|
var streamBuf = getStreamContent(inputStream);
|
|
|
|
inputStream.close();
|
|
|
|
var lines = streamBuf.split(/(\n|\r|\r\n)/);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-08-06 15:38:44 -07:00
|
|
|
// Build the sandbox for fails-if(), etc., condition evaluation.
|
2010-03-30 13:58:30 -07:00
|
|
|
var sandbox = new Components.utils.Sandbox(aURL.spec);
|
2009-02-03 06:11:28 -08:00
|
|
|
var xr = CC[NS_XREAPPINFO_CONTRACTID].getService(CI.nsIXULRuntime);
|
|
|
|
sandbox.MOZ_WIDGET_TOOLKIT = xr.widgetToolkit;
|
2009-08-20 00:56:22 -07:00
|
|
|
sandbox.isDebugBuild = gDebug.isDebugBuild;
|
2009-10-22 13:36:24 -07:00
|
|
|
sandbox.xulRuntime = {widgetToolkit: xr.widgetToolkit, OS: xr.OS};
|
2009-06-19 11:17:55 -07:00
|
|
|
|
2009-10-22 13:36:24 -07:00
|
|
|
// xr.XPCOMABI throws exception for configurations without full ABI
|
|
|
|
// support (mobile builds on ARM)
|
2009-06-19 11:17:55 -07:00
|
|
|
try {
|
2009-10-22 13:36:24 -07:00
|
|
|
sandbox.xulRuntime.XPCOMABI = xr.XPCOMABI;
|
|
|
|
} catch(e) {
|
|
|
|
sandbox.xulRuntime.XPCOMABI = "";
|
|
|
|
}
|
2009-06-19 11:17:55 -07:00
|
|
|
|
2008-08-06 15:38:44 -07:00
|
|
|
var hh = CC[NS_NETWORK_PROTOCOL_CONTRACTID_PREFIX + "http"].
|
|
|
|
getService(CI.nsIHttpProtocolHandler);
|
|
|
|
sandbox.http = {};
|
2009-05-14 07:17:45 -07:00
|
|
|
for each (var prop in [ "userAgent", "appName", "appVersion",
|
2008-08-06 15:38:44 -07:00
|
|
|
"vendor", "vendorSub", "vendorComment",
|
|
|
|
"product", "productSub", "productComment",
|
|
|
|
"platform", "oscpu", "language", "misc" ])
|
|
|
|
sandbox.http[prop] = hh[prop];
|
2009-01-16 12:03:24 -08:00
|
|
|
// see if we have the test plugin available,
|
|
|
|
// and set a sandox prop accordingly
|
|
|
|
sandbox.haveTestPlugin = false;
|
|
|
|
for (var i = 0; i < navigator.mimeTypes.length; i++) {
|
|
|
|
if (navigator.mimeTypes[i].type == "application/x-test" &&
|
|
|
|
navigator.mimeTypes[i].enabledPlugin != null &&
|
|
|
|
navigator.mimeTypes[i].enabledPlugin.name == "Test Plug-in") {
|
|
|
|
sandbox.haveTestPlugin = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-02-05 13:07:24 -08:00
|
|
|
// Set a flag on sandbox if the windows default theme is active
|
|
|
|
var box = document.createElement("box");
|
|
|
|
box.setAttribute("id", "_box_windowsDefaultTheme");
|
|
|
|
document.documentElement.appendChild(box);
|
|
|
|
sandbox.windowsDefaultTheme = (getComputedStyle(box, null).display == "none");
|
|
|
|
document.documentElement.removeChild(box);
|
|
|
|
|
2010-03-02 14:14:14 -08:00
|
|
|
var prefs = CC["@mozilla.org/preferences-service;1"].
|
|
|
|
getService(CI.nsIPrefBranch2);
|
|
|
|
try {
|
|
|
|
sandbox.nativeThemePref = !prefs.getBoolPref("mozilla.widget.disable-native-theme");
|
|
|
|
} catch (e) {
|
|
|
|
sandbox.nativeThemePref = true;
|
|
|
|
}
|
|
|
|
|
2010-03-29 14:56:46 -07:00
|
|
|
new XPCSafeJSObjectWrapper(sandbox).prefs = {
|
|
|
|
__exposedProps__: {
|
2010-04-07 16:35:09 -07:00
|
|
|
getBoolPref: 'r',
|
2010-03-29 14:56:46 -07:00
|
|
|
getIntPref: 'r',
|
|
|
|
},
|
|
|
|
_prefs: prefs,
|
2010-04-07 16:35:09 -07:00
|
|
|
getBoolPref: function(p) { return this._prefs.getBoolPref(p); },
|
2010-03-29 14:56:46 -07:00
|
|
|
getIntPref: function(p) { return this._prefs.getIntPref(p) }
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
var lineNo = 0;
|
2009-09-26 15:54:12 -07:00
|
|
|
var urlprefix = "";
|
2010-03-12 14:31:53 -08:00
|
|
|
for each (var str in lines) {
|
2007-03-22 10:30:00 -07:00
|
|
|
++lineNo;
|
2007-12-20 15:49:00 -08:00
|
|
|
if (str.charAt(0) == "#")
|
2007-03-22 10:30:00 -07:00
|
|
|
continue; // entire line was a comment
|
2007-12-20 15:49:00 -08:00
|
|
|
var i = str.search(/\s+#/);
|
|
|
|
if (i >= 0)
|
|
|
|
str = str.substring(0, i);
|
2007-03-22 10:30:00 -07:00
|
|
|
// strip leading and trailing whitespace
|
|
|
|
str = str.replace(/^\s*/, '').replace(/\s*$/, '');
|
|
|
|
if (!str || str == "")
|
|
|
|
continue;
|
|
|
|
var items = str.split(/\s+/); // split on whitespace
|
|
|
|
|
2009-09-26 15:54:12 -07:00
|
|
|
if (items[0] == "url-prefix") {
|
|
|
|
if (items.length != 2)
|
|
|
|
throw "url-prefix requires one url in manifest file " + aURL.spec + " line " + lineNo;
|
|
|
|
urlprefix = items[1];
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
var expected_status = EXPECTED_PASS;
|
2009-01-08 13:50:21 -08:00
|
|
|
var minAsserts = 0;
|
|
|
|
var maxAsserts = 0;
|
|
|
|
while (items[0].match(/^(fails|random|skip|asserts)/)) {
|
2007-03-22 10:30:00 -07:00
|
|
|
var item = items.shift();
|
|
|
|
var stat;
|
|
|
|
var cond;
|
2007-05-08 03:21:22 -07:00
|
|
|
var m = item.match(/^(fails|random|skip)-if(\(.*\))$/);
|
2007-03-22 10:30:00 -07:00
|
|
|
if (m) {
|
|
|
|
stat = m[1];
|
|
|
|
// Note: m[2] contains the parentheses, and we want them.
|
|
|
|
cond = Components.utils.evalInSandbox(m[2], sandbox);
|
2007-05-08 03:21:22 -07:00
|
|
|
} else if (item.match(/^(fails|random|skip)$/)) {
|
2007-03-22 10:30:00 -07:00
|
|
|
stat = item;
|
|
|
|
cond = true;
|
2009-01-08 13:50:21 -08:00
|
|
|
} else if ((m = item.match(/^asserts\((\d+)(-\d+)?\)$/))) {
|
|
|
|
cond = false;
|
|
|
|
minAsserts = Number(m[1]);
|
|
|
|
maxAsserts = (m[2] == undefined) ? minAsserts
|
|
|
|
: Number(m[2].substring(1));
|
|
|
|
} else if ((m = item.match(/^asserts-if\((.*?),(\d+)(-\d+)?\)$/))) {
|
|
|
|
cond = false;
|
|
|
|
if (Components.utils.evalInSandbox("(" + m[1] + ")", sandbox)) {
|
|
|
|
minAsserts = Number(m[2]);
|
|
|
|
maxAsserts =
|
|
|
|
(m[3] == undefined) ? minAsserts
|
|
|
|
: Number(m[3].substring(1));
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
} else {
|
2009-08-20 00:56:22 -07:00
|
|
|
throw "Error 1 in manifest file " + aURL.spec + " line " + lineNo;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if (cond) {
|
|
|
|
if (stat == "fails") {
|
|
|
|
expected_status = EXPECTED_FAIL;
|
|
|
|
} else if (stat == "random") {
|
|
|
|
expected_status = EXPECTED_RANDOM;
|
2007-05-08 03:21:22 -07:00
|
|
|
} else if (stat == "skip") {
|
|
|
|
expected_status = EXPECTED_DEATH;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-08 13:50:21 -08:00
|
|
|
if (minAsserts > maxAsserts) {
|
|
|
|
throw "Bad range in manifest file " + aURL.spec + " line " + lineNo;
|
|
|
|
}
|
|
|
|
|
2008-11-08 08:35:54 -08:00
|
|
|
var runHttp = false;
|
|
|
|
var httpDepth;
|
|
|
|
if (items[0] == "HTTP") {
|
2010-03-12 14:31:53 -08:00
|
|
|
runHttp = (aURL.scheme == "file"); // We can't yet run the local HTTP server
|
|
|
|
// for non-local reftests.
|
2008-11-08 08:35:54 -08:00
|
|
|
httpDepth = 0;
|
2007-07-18 14:32:50 -07:00
|
|
|
items.shift();
|
2008-11-08 08:35:54 -08:00
|
|
|
} else if (items[0].match(/HTTP\(\.\.(\/\.\.)*\)/)) {
|
|
|
|
// Accept HTTP(..), HTTP(../..), HTTP(../../..), etc.
|
2010-03-12 14:31:53 -08:00
|
|
|
runHttp = (aURL.scheme == "file"); // We can't yet run the local HTTP server
|
|
|
|
// for non-local reftests.
|
2008-11-08 08:35:54 -08:00
|
|
|
httpDepth = (items[0].length - 5) / 3;
|
|
|
|
items.shift();
|
|
|
|
}
|
2007-07-18 14:32:50 -07:00
|
|
|
|
2009-09-26 15:54:12 -07:00
|
|
|
// do not prefix the url for include commands or urls specifying
|
|
|
|
// a protocol
|
|
|
|
if (urlprefix && items[0] != "include") {
|
|
|
|
if (items.length > 1 && !items[1].match(gProtocolRE)) {
|
|
|
|
items[1] = urlprefix + items[1];
|
|
|
|
}
|
|
|
|
if (items.length > 2 && !items[2].match(gProtocolRE)) {
|
|
|
|
items[2] = urlprefix + items[2];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
if (items[0] == "include") {
|
2007-07-18 14:32:50 -07:00
|
|
|
if (items.length != 2 || runHttp)
|
2009-08-20 00:56:22 -07:00
|
|
|
throw "Error 2 in manifest file " + aURL.spec + " line " + lineNo;
|
2007-07-18 14:32:50 -07:00
|
|
|
var incURI = gIOService.newURI(items[1], null, listURL);
|
2007-06-12 11:25:15 -07:00
|
|
|
secMan.checkLoadURI(aURL, incURI,
|
|
|
|
CI.nsIScriptSecurityManager.DISALLOW_SCRIPT);
|
|
|
|
ReadManifest(incURI);
|
2009-08-20 00:56:22 -07:00
|
|
|
} else if (items[0] == TYPE_LOAD) {
|
2007-10-03 14:27:04 -07:00
|
|
|
if (items.length != 2 ||
|
2009-08-20 00:56:22 -07:00
|
|
|
(expected_status != EXPECTED_PASS &&
|
2007-10-03 14:27:04 -07:00
|
|
|
expected_status != EXPECTED_DEATH))
|
2009-08-20 00:56:22 -07:00
|
|
|
throw "Error 3 in manifest file " + aURL.spec + " line " + lineNo;
|
2007-10-03 14:27:04 -07:00
|
|
|
var [testURI] = runHttp
|
2008-11-08 08:35:54 -08:00
|
|
|
? ServeFiles(aURL, httpDepth,
|
2010-03-12 14:31:53 -08:00
|
|
|
listURL, [items[1]])
|
2007-10-03 14:27:04 -07:00
|
|
|
: [gIOService.newURI(items[1], null, listURL)];
|
|
|
|
var prettyPath = runHttp
|
|
|
|
? gIOService.newURI(items[1], null, listURL).spec
|
|
|
|
: testURI.spec;
|
|
|
|
secMan.checkLoadURI(aURL, testURI,
|
|
|
|
CI.nsIScriptSecurityManager.DISALLOW_SCRIPT);
|
2009-08-20 00:56:22 -07:00
|
|
|
gURLs.push( { type: TYPE_LOAD,
|
2007-10-03 14:27:04 -07:00
|
|
|
expected: expected_status,
|
|
|
|
prettyPath: prettyPath,
|
2009-01-08 13:50:21 -08:00
|
|
|
minAsserts: minAsserts,
|
|
|
|
maxAsserts: maxAsserts,
|
2008-12-16 18:15:38 -08:00
|
|
|
url1: testURI,
|
|
|
|
url2: null } );
|
2009-08-20 00:56:22 -07:00
|
|
|
} else if (items[0] == TYPE_SCRIPT) {
|
|
|
|
if (items.length != 2)
|
2009-08-20 00:56:22 -07:00
|
|
|
throw "Error 4 in manifest file " + aURL.spec + " line " + lineNo;
|
2009-08-20 00:56:22 -07:00
|
|
|
var [testURI] = runHttp
|
|
|
|
? ServeFiles(aURL, httpDepth,
|
2010-03-12 14:31:53 -08:00
|
|
|
listURL, [items[1]])
|
2009-08-20 00:56:22 -07:00
|
|
|
: [gIOService.newURI(items[1], null, listURL)];
|
|
|
|
var prettyPath = runHttp
|
|
|
|
? gIOService.newURI(items[1], null, listURL).spec
|
|
|
|
: testURI.spec;
|
|
|
|
secMan.checkLoadURI(aURL, testURI,
|
|
|
|
CI.nsIScriptSecurityManager.DISALLOW_SCRIPT);
|
|
|
|
gURLs.push( { type: TYPE_SCRIPT,
|
|
|
|
expected: expected_status,
|
|
|
|
prettyPath: prettyPath,
|
|
|
|
minAsserts: minAsserts,
|
|
|
|
maxAsserts: maxAsserts,
|
|
|
|
url1: testURI,
|
|
|
|
url2: null } );
|
|
|
|
} else if (items[0] == TYPE_REFTEST_EQUAL || items[0] == TYPE_REFTEST_NOTEQUAL) {
|
|
|
|
if (items.length != 3)
|
|
|
|
throw "Error 5 in manifest file " + aURL.spec + " line " + lineNo;
|
2007-07-18 14:32:50 -07:00
|
|
|
var [testURI, refURI] = runHttp
|
2008-11-08 08:35:54 -08:00
|
|
|
? ServeFiles(aURL, httpDepth,
|
2010-03-12 14:31:53 -08:00
|
|
|
listURL, [items[1], items[2]])
|
2007-07-18 14:32:50 -07:00
|
|
|
: [gIOService.newURI(items[1], null, listURL),
|
|
|
|
gIOService.newURI(items[2], null, listURL)];
|
|
|
|
var prettyPath = runHttp
|
|
|
|
? gIOService.newURI(items[1], null, listURL).spec
|
|
|
|
: testURI.spec;
|
2007-06-12 11:25:15 -07:00
|
|
|
secMan.checkLoadURI(aURL, testURI,
|
|
|
|
CI.nsIScriptSecurityManager.DISALLOW_SCRIPT);
|
|
|
|
secMan.checkLoadURI(aURL, refURI,
|
|
|
|
CI.nsIScriptSecurityManager.DISALLOW_SCRIPT);
|
2009-08-20 00:56:22 -07:00
|
|
|
gURLs.push( { type: items[0],
|
2007-03-22 10:30:00 -07:00
|
|
|
expected: expected_status,
|
2007-07-18 14:32:50 -07:00
|
|
|
prettyPath: prettyPath,
|
2009-01-08 13:50:21 -08:00
|
|
|
minAsserts: minAsserts,
|
|
|
|
maxAsserts: maxAsserts,
|
2008-12-16 18:15:38 -08:00
|
|
|
url1: testURI,
|
|
|
|
url2: refURI } );
|
2007-03-22 10:30:00 -07:00
|
|
|
} else {
|
2009-08-20 00:56:22 -07:00
|
|
|
throw "Error 6 in manifest file " + aURL.spec + " line " + lineNo;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2010-03-12 14:31:53 -08:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2008-12-16 18:15:38 -08:00
|
|
|
function AddURIUseCount(uri)
|
2008-12-07 16:48:36 -08:00
|
|
|
{
|
|
|
|
if (uri == null)
|
|
|
|
return;
|
|
|
|
|
2008-12-16 18:15:38 -08:00
|
|
|
var spec = uri.spec;
|
2008-12-07 16:48:36 -08:00
|
|
|
if (spec in gURIUseCounts) {
|
|
|
|
gURIUseCounts[spec]++;
|
|
|
|
} else {
|
|
|
|
gURIUseCounts[spec] = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function BuildUseCounts()
|
|
|
|
{
|
|
|
|
gURIUseCounts = {};
|
|
|
|
for (var i = 0; i < gURLs.length; ++i) {
|
2009-08-20 00:56:22 -07:00
|
|
|
var url = gURLs[i];
|
|
|
|
if (url.expected != EXPECTED_DEATH &&
|
|
|
|
(url.type == TYPE_REFTEST_EQUAL ||
|
|
|
|
url.type == TYPE_REFTEST_NOTEQUAL)) {
|
2008-12-16 18:15:38 -08:00
|
|
|
AddURIUseCount(gURLs[i].url1);
|
|
|
|
AddURIUseCount(gURLs[i].url2);
|
2008-12-07 16:48:36 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-03-12 14:31:53 -08:00
|
|
|
function ServeFiles(manifestURL, depth, aURL, files)
|
2007-07-18 14:32:50 -07:00
|
|
|
{
|
2010-03-12 14:31:53 -08:00
|
|
|
var listURL = aURL.QueryInterface(CI.nsIFileURL);
|
|
|
|
var directory = listURL.file.parent;
|
|
|
|
|
2008-11-08 08:35:54 -08:00
|
|
|
// Allow serving a tree that's an ancestor of the directory containing
|
|
|
|
// the files so that they can use resources in ../ (etc.).
|
|
|
|
var dirPath = "/";
|
|
|
|
while (depth > 0) {
|
|
|
|
dirPath = "/" + directory.leafName + dirPath;
|
|
|
|
directory = directory.parent;
|
|
|
|
--depth;
|
|
|
|
}
|
|
|
|
|
2007-07-18 14:32:50 -07:00
|
|
|
gCount++;
|
2009-02-20 22:07:14 -08:00
|
|
|
var path = "/" + Date.now() + "/" + gCount;
|
2008-11-08 08:35:54 -08:00
|
|
|
gServer.registerDirectory(path + "/", directory);
|
2007-07-18 14:32:50 -07:00
|
|
|
|
|
|
|
var secMan = CC[NS_SCRIPTSECURITYMANAGER_CONTRACTID]
|
|
|
|
.getService(CI.nsIScriptSecurityManager);
|
|
|
|
|
2008-11-08 08:35:54 -08:00
|
|
|
var testbase = gIOService.newURI("http://localhost:" + HTTP_SERVER_PORT +
|
|
|
|
path + dirPath,
|
|
|
|
null, null);
|
2008-11-08 08:35:54 -08:00
|
|
|
|
2007-10-03 14:27:04 -07:00
|
|
|
function FileToURI(file)
|
|
|
|
{
|
2008-11-08 08:35:54 -08:00
|
|
|
// Only serve relative URIs via the HTTP server, not absolute
|
|
|
|
// ones like about:blank.
|
|
|
|
var testURI = gIOService.newURI(file, null, testbase);
|
2007-10-03 14:27:04 -07:00
|
|
|
|
|
|
|
// XXX necessary? manifestURL guaranteed to be file, others always HTTP
|
|
|
|
secMan.checkLoadURI(manifestURL, testURI,
|
|
|
|
CI.nsIScriptSecurityManager.DISALLOW_SCRIPT);
|
2007-07-18 14:32:50 -07:00
|
|
|
|
2007-10-03 14:27:04 -07:00
|
|
|
return testURI;
|
|
|
|
}
|
|
|
|
|
|
|
|
return files.map(FileToURI);
|
2007-07-18 14:32:50 -07:00
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
function StartCurrentTest()
|
|
|
|
{
|
2007-05-08 03:21:22 -07:00
|
|
|
// make sure we don't run tests that are expected to kill the browser
|
|
|
|
while (gURLs.length > 0 && gURLs[0].expected == EXPECTED_DEATH) {
|
2008-12-02 04:35:24 -08:00
|
|
|
++gTestResults.Skip;
|
2008-12-16 18:15:38 -08:00
|
|
|
dump("REFTEST TEST-KNOWN-FAIL | " + gURLs[0].url1.spec + " | (SKIP)\n");
|
2007-05-08 03:21:22 -07:00
|
|
|
gURLs.shift();
|
|
|
|
}
|
|
|
|
|
2008-07-19 13:54:47 -07:00
|
|
|
if (gURLs.length == 0) {
|
2007-03-22 10:30:00 -07:00
|
|
|
DoneTests();
|
2008-07-19 13:54:47 -07:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
var currentTest = gTotalTests - gURLs.length;
|
2008-08-04 00:21:47 -07:00
|
|
|
document.title = "reftest: " + currentTest + " / " + gTotalTests +
|
2008-07-19 13:54:47 -07:00
|
|
|
" (" + Math.floor(100 * (currentTest / gTotalTests)) + "%)";
|
2008-12-16 18:15:38 -08:00
|
|
|
StartCurrentURI(1);
|
2008-07-19 13:54:47 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function StartCurrentURI(aState)
|
|
|
|
{
|
2008-04-29 17:39:45 -07:00
|
|
|
gCurrentTestStartTime = Date.now();
|
2009-02-08 10:28:30 -08:00
|
|
|
if (gFailureTimeout != null) {
|
2009-05-14 07:17:45 -07:00
|
|
|
dump("REFTEST TEST-UNEXPECTED-FAIL | " +
|
2009-02-08 10:28:30 -08:00
|
|
|
"| program error managing timeouts\n");
|
|
|
|
++gTestResults.Exception;
|
|
|
|
}
|
2009-06-19 11:17:55 -07:00
|
|
|
gFailureTimeout = setTimeout(LoadFailed, gLoadTimeout);
|
2008-10-19 13:27:46 -07:00
|
|
|
gFailureReason = "timed out waiting for onload to fire";
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
gState = aState;
|
2008-10-19 13:27:46 -07:00
|
|
|
gCurrentURL = gURLs[0]["url" + aState].spec;
|
2008-12-07 16:48:36 -08:00
|
|
|
|
2009-08-20 00:56:22 -07:00
|
|
|
if (gURICanvases[gCurrentURL] &&
|
|
|
|
(gURLs[0].type == TYPE_REFTEST_EQUAL ||
|
|
|
|
gURLs[0].type == TYPE_REFTEST_NOTEQUAL) &&
|
2009-01-08 13:50:21 -08:00
|
|
|
gURLs[0].maxAsserts == 0) {
|
2008-12-07 16:48:36 -08:00
|
|
|
// Pretend the document loaded --- DocumentLoaded will notice
|
|
|
|
// there's already a canvas for this URL
|
|
|
|
setTimeout(DocumentLoaded, 0);
|
|
|
|
} else {
|
2010-01-18 15:00:16 -08:00
|
|
|
dump("REFTEST INFO | Loading " + gCurrentURL + "\n");
|
2008-12-07 16:48:36 -08:00
|
|
|
gBrowser.loadURI(gCurrentURL);
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
function DoneTests()
|
|
|
|
{
|
2008-04-29 17:39:45 -07:00
|
|
|
dump("REFTEST FINISHED: Slowest test took " + gSlowestTestTime +
|
|
|
|
"ms (" + gSlowestTestURL + ")\n");
|
|
|
|
|
2008-12-02 04:35:24 -08:00
|
|
|
dump("REFTEST INFO | Result summary:\n");
|
2008-12-11 15:48:32 -08:00
|
|
|
var count = gTestResults.Pass + gTestResults.LoadOnly;
|
|
|
|
dump("REFTEST INFO | Successful: " + count + " (" +
|
|
|
|
gTestResults.Pass + " pass, " +
|
|
|
|
gTestResults.LoadOnly + " load only)\n");
|
|
|
|
count = gTestResults.Exception + gTestResults.FailedLoad +
|
2009-01-08 13:50:21 -08:00
|
|
|
gTestResults.UnexpectedFail + gTestResults.UnexpectedPass +
|
|
|
|
gTestResults.AssertionUnexpected +
|
|
|
|
gTestResults.AssertionUnexpectedFixed;
|
2008-12-11 15:48:32 -08:00
|
|
|
dump("REFTEST INFO | Unexpected: " + count + " (" +
|
|
|
|
gTestResults.UnexpectedFail + " unexpected fail, " +
|
|
|
|
gTestResults.UnexpectedPass + " unexpected pass, " +
|
2009-01-08 13:50:21 -08:00
|
|
|
gTestResults.AssertionUnexpected + " unexpected asserts, " +
|
|
|
|
gTestResults.AssertionUnexpectedFixed + " unexpected fixed asserts, " +
|
2008-12-11 15:48:32 -08:00
|
|
|
gTestResults.FailedLoad + " failed load, " +
|
|
|
|
gTestResults.Exception + " exception)\n");
|
2009-01-08 13:50:21 -08:00
|
|
|
count = gTestResults.KnownFail + gTestResults.AssertionKnown +
|
|
|
|
gTestResults.Random + gTestResults.Skip;
|
2008-12-11 15:48:32 -08:00
|
|
|
dump("REFTEST INFO | Known problems: " + count + " (" +
|
|
|
|
gTestResults.KnownFail + " known fail, " +
|
2009-01-08 13:50:21 -08:00
|
|
|
gTestResults.AssertionKnown + " known asserts, " +
|
2008-12-11 15:48:32 -08:00
|
|
|
gTestResults.Random + " random, " +
|
|
|
|
gTestResults.Skip + " skipped)\n");
|
2008-12-02 04:35:24 -08:00
|
|
|
|
2008-12-07 16:48:36 -08:00
|
|
|
dump("REFTEST INFO | Total canvas count = " + gRecycledCanvases.length + "\n");
|
|
|
|
|
2009-04-15 13:19:35 -07:00
|
|
|
function onStopped() {
|
|
|
|
dump("REFTEST INFO | Quitting...\n");
|
|
|
|
goQuitApplication();
|
|
|
|
}
|
2007-07-18 14:32:50 -07:00
|
|
|
if (gServer)
|
2009-04-15 13:19:35 -07:00
|
|
|
gServer.stop(onStopped);
|
|
|
|
else
|
|
|
|
onStopped();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2008-10-15 13:49:42 -07:00
|
|
|
function setupZoom(contentRootElement) {
|
2009-08-08 17:50:50 -07:00
|
|
|
if (!contentRootElement || !contentRootElement.hasAttribute('reftest-zoom'))
|
2008-10-15 13:49:42 -07:00
|
|
|
return;
|
|
|
|
gBrowser.markupDocumentViewer.fullZoom =
|
|
|
|
contentRootElement.getAttribute('reftest-zoom');
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2008-10-15 13:49:42 -07:00
|
|
|
function resetZoom() {
|
|
|
|
gBrowser.markupDocumentViewer.fullZoom = 1.0;
|
|
|
|
}
|
2009-05-14 07:17:45 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
function OnDocumentLoad(event)
|
|
|
|
{
|
|
|
|
if (event.target != gBrowser.contentDocument)
|
|
|
|
// Ignore load events for subframes.
|
|
|
|
return;
|
2009-05-14 07:17:45 -07:00
|
|
|
|
2009-02-10 14:05:27 -08:00
|
|
|
if (gClearingForAssertionCheck &&
|
|
|
|
gBrowser.contentDocument.location.href == BLANK_URL_FOR_CLEARING) {
|
2009-01-08 13:50:21 -08:00
|
|
|
DoAssertionCheck();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2008-10-19 13:27:46 -07:00
|
|
|
if (gBrowser.contentDocument.location.href != gCurrentURL)
|
|
|
|
// Ignore load events for previous documents.
|
|
|
|
return;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-03-27 11:06:35 -07:00
|
|
|
var contentRootElement = gBrowser.contentDocument.documentElement;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
function shouldWait() {
|
2007-03-27 11:06:35 -07:00
|
|
|
// use getAttribute because className works differently in HTML and SVG
|
2009-08-08 17:50:50 -07:00
|
|
|
return contentRootElement &&
|
|
|
|
contentRootElement.hasAttribute('class') &&
|
2007-03-27 11:06:35 -07:00
|
|
|
contentRootElement.getAttribute('class').split(/\s+/)
|
2007-03-22 10:30:00 -07:00
|
|
|
.indexOf("reftest-wait") != -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
function doPrintMode() {
|
2007-03-27 11:06:35 -07:00
|
|
|
// use getAttribute because className works differently in HTML and SVG
|
2009-08-08 17:50:50 -07:00
|
|
|
return contentRootElement &&
|
|
|
|
contentRootElement.hasAttribute('class') &&
|
2007-03-27 11:06:35 -07:00
|
|
|
contentRootElement.getAttribute('class').split(/\s+/)
|
2007-03-22 10:30:00 -07:00
|
|
|
.indexOf("reftest-print") != -1;
|
|
|
|
}
|
|
|
|
|
2008-09-05 17:30:45 -07:00
|
|
|
function setupPrintMode() {
|
|
|
|
var PSSVC = Components.classes["@mozilla.org/gfx/printsettings-service;1"]
|
|
|
|
.getService(Components.interfaces.nsIPrintSettingsService);
|
|
|
|
var ps = PSSVC.newPrintSettings;
|
|
|
|
ps.paperWidth = 5;
|
|
|
|
ps.paperHeight = 3;
|
|
|
|
|
|
|
|
// Override any os-specific unwriteable margins
|
|
|
|
ps.unwriteableMarginTop = 0;
|
|
|
|
ps.unwriteableMarginLeft = 0;
|
|
|
|
ps.unwriteableMarginBottom = 0;
|
|
|
|
ps.unwriteableMarginRight = 0;
|
|
|
|
|
|
|
|
ps.headerStrLeft = "";
|
|
|
|
ps.headerStrCenter = "";
|
|
|
|
ps.headerStrRight = "";
|
|
|
|
ps.footerStrLeft = "";
|
|
|
|
ps.footerStrCenter = "";
|
|
|
|
ps.footerStrRight = "";
|
|
|
|
gBrowser.docShell.contentViewer.setPageMode(true, ps);
|
|
|
|
}
|
|
|
|
|
2008-10-15 13:49:42 -07:00
|
|
|
setupZoom(contentRootElement);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
if (shouldWait()) {
|
|
|
|
// The testcase will let us know when the test snapshot should be made.
|
|
|
|
// Register a mutation listener to know when the 'reftest-wait' class
|
|
|
|
// gets removed.
|
2008-10-19 13:27:46 -07:00
|
|
|
gFailureReason = "timed out waiting for reftest-wait to be removed (after onload fired)"
|
2009-01-05 17:15:13 -08:00
|
|
|
|
|
|
|
var stopAfterPaintReceived = false;
|
|
|
|
var currentDoc = gBrowser.contentDocument;
|
|
|
|
var utils = gBrowser.contentWindow.QueryInterface(CI.nsIInterfaceRequestor)
|
|
|
|
.getInterface(CI.nsIDOMWindowUtils);
|
|
|
|
|
|
|
|
function FlushRendering() {
|
|
|
|
// Flush pending restyles and reflows
|
|
|
|
contentRootElement.getBoundingClientRect();
|
|
|
|
// Flush out invalidation
|
|
|
|
utils.processUpdates();
|
|
|
|
}
|
|
|
|
|
2009-01-07 00:31:36 -08:00
|
|
|
function WhenMozAfterPaintFlushed(continuation) {
|
|
|
|
if (utils.isMozAfterPaintPending) {
|
|
|
|
function handler() {
|
|
|
|
gBrowser.removeEventListener("MozAfterPaint", handler, false);
|
|
|
|
continuation();
|
|
|
|
}
|
|
|
|
gBrowser.addEventListener("MozAfterPaint", handler, false);
|
|
|
|
} else {
|
|
|
|
continuation();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-05 17:15:13 -08:00
|
|
|
function AfterPaintListener(event) {
|
|
|
|
if (event.target.document != currentDoc) {
|
|
|
|
// ignore paint events for subframes or old documents in the window.
|
|
|
|
// Invalidation in subframes will cause invalidation in the main document anyway.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
FlushRendering();
|
|
|
|
UpdateCurrentCanvasForEvent(event);
|
|
|
|
// When stopAfteraintReceived is set, we can stop --- but we should keep going as long
|
|
|
|
// as there are paint events coming (there probably shouldn't be any, but it doesn't
|
|
|
|
// hurt to process them)
|
|
|
|
if (stopAfterPaintReceived && !utils.isMozAfterPaintPending) {
|
|
|
|
FinishWaitingForTestEnd();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function FinishWaitingForTestEnd() {
|
|
|
|
gBrowser.removeEventListener("MozAfterPaint", AfterPaintListener, false);
|
|
|
|
setTimeout(DocumentLoaded, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
function AttrModifiedListener() {
|
|
|
|
if (shouldWait())
|
|
|
|
return;
|
|
|
|
|
|
|
|
// We don't want to be notified again
|
|
|
|
contentRootElement.removeEventListener("DOMAttrModified", AttrModifiedListener, false);
|
2009-01-21 20:15:40 -08:00
|
|
|
// Wait for the next return-to-event-loop before continuing to flush rendering and
|
|
|
|
// check isMozAfterPaintPending --- for example, the attribute may have been modified
|
|
|
|
// in an subdocument's load event handler, in which case we need load event processing
|
|
|
|
// to complete and unsuppress painting before we check isMozAfterPaintPending.
|
|
|
|
setTimeout(AttrModifiedListenerContinuation, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
function AttrModifiedListenerContinuation() {
|
2009-01-05 17:15:13 -08:00
|
|
|
if (doPrintMode())
|
|
|
|
setupPrintMode();
|
|
|
|
FlushRendering();
|
|
|
|
|
|
|
|
if (utils.isMozAfterPaintPending) {
|
|
|
|
// Wait for the last invalidation to have happened and been snapshotted before
|
|
|
|
// we stop the test
|
|
|
|
stopAfterPaintReceived = true;
|
|
|
|
} else {
|
|
|
|
// Nothing to wait for, so stop now
|
|
|
|
FinishWaitingForTestEnd();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function StartWaitingForTestEnd() {
|
|
|
|
FlushRendering();
|
|
|
|
|
2009-01-07 00:31:36 -08:00
|
|
|
function continuation() {
|
|
|
|
gBrowser.addEventListener("MozAfterPaint", AfterPaintListener, false);
|
|
|
|
contentRootElement.addEventListener("DOMAttrModified", AttrModifiedListener, false);
|
2009-01-05 17:15:13 -08:00
|
|
|
|
2009-01-07 00:31:36 -08:00
|
|
|
// Take a snapshot of the window in its current state
|
|
|
|
InitCurrentCanvasWithSnapshot();
|
2009-01-05 17:15:13 -08:00
|
|
|
|
2009-01-07 00:31:36 -08:00
|
|
|
if (!shouldWait()) {
|
|
|
|
// reftest-wait was already removed (during the interval between OnDocumentLoaded
|
|
|
|
// calling setTimeout(StartWaitingForTestEnd,0) below, and this function
|
|
|
|
// actually running), so let's fake a direct notification of the attribute
|
|
|
|
// change.
|
|
|
|
AttrModifiedListener();
|
|
|
|
return;
|
|
|
|
}
|
2009-01-05 17:15:13 -08:00
|
|
|
|
2009-01-07 00:31:36 -08:00
|
|
|
// Notify the test document that now is a good time to test some invalidation
|
|
|
|
var notification = document.createEvent("Events");
|
|
|
|
notification.initEvent("MozReftestInvalidate", true, false);
|
|
|
|
contentRootElement.dispatchEvent(notification);
|
|
|
|
}
|
|
|
|
WhenMozAfterPaintFlushed(continuation);
|
2009-01-05 17:15:13 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
// After this load event has finished being dispatched, painting is normally
|
|
|
|
// unsuppressed, which invalidates the entire window. So ensure
|
|
|
|
// StartWaitingForTestEnd runs after that invalidation has been requested.
|
|
|
|
setTimeout(StartWaitingForTestEnd, 0);
|
2007-03-22 10:30:00 -07:00
|
|
|
} else {
|
2008-09-05 17:30:45 -07:00
|
|
|
if (doPrintMode())
|
|
|
|
setupPrintMode();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Since we can't use a bubbling-phase load listener from chrome,
|
|
|
|
// this is a capturing phase listener. So do setTimeout twice, the
|
|
|
|
// first to get us after the onload has fired in the content, and
|
|
|
|
// the second to get us after any setTimeout(foo, 0) in the content.
|
|
|
|
setTimeout(setTimeout, 0, DocumentLoaded, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-16 18:15:38 -08:00
|
|
|
function UpdateCanvasCache(url, canvas)
|
2008-12-07 16:48:36 -08:00
|
|
|
{
|
2008-12-16 18:15:38 -08:00
|
|
|
var spec = url.spec;
|
2008-12-07 16:48:36 -08:00
|
|
|
|
|
|
|
--gURIUseCounts[spec];
|
2009-09-22 13:01:11 -07:00
|
|
|
|
|
|
|
if (gNoCanvasCache || gURIUseCounts[spec] == 0) {
|
2008-12-07 16:48:36 -08:00
|
|
|
ReleaseCanvas(canvas);
|
|
|
|
delete gURICanvases[spec];
|
|
|
|
} else if (gURIUseCounts[spec] > 0) {
|
|
|
|
gURICanvases[spec] = canvas;
|
|
|
|
} else {
|
|
|
|
throw "Use counts were computed incorrectly";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-05 17:15:13 -08:00
|
|
|
function InitCurrentCanvasWithSnapshot()
|
|
|
|
{
|
|
|
|
gCurrentCanvas = AllocateCanvas();
|
|
|
|
|
|
|
|
/* XXX This needs to be rgb(255,255,255) because otherwise we get
|
|
|
|
* black bars at the bottom of every test that are different size
|
|
|
|
* for the first test and the rest (scrollbar-related??) */
|
|
|
|
var win = gBrowser.contentWindow;
|
|
|
|
var ctx = gCurrentCanvas.getContext("2d");
|
|
|
|
var scale = gBrowser.markupDocumentViewer.fullZoom;
|
|
|
|
ctx.save();
|
|
|
|
// drawWindow always draws one canvas pixel for each CSS pixel in the source
|
|
|
|
// window, so scale the drawing to show the zoom (making each canvas pixel be one
|
|
|
|
// device pixel instead)
|
|
|
|
ctx.scale(scale, scale);
|
|
|
|
ctx.drawWindow(win, win.scrollX, win.scrollY,
|
|
|
|
Math.ceil(gCurrentCanvas.width / scale),
|
|
|
|
Math.ceil(gCurrentCanvas.height / scale),
|
2009-10-16 03:55:49 -07:00
|
|
|
"rgb(255,255,255)",
|
2010-03-01 00:03:49 -08:00
|
|
|
ctx.DRAWWINDOW_DRAW_CARET |
|
|
|
|
ctx.DRAWWINDOW_USE_WIDGET_LAYERS);
|
2009-01-05 17:15:13 -08:00
|
|
|
ctx.restore();
|
|
|
|
}
|
|
|
|
|
|
|
|
function roundTo(x, fraction)
|
|
|
|
{
|
|
|
|
return Math.round(x/fraction)*fraction;
|
|
|
|
}
|
|
|
|
|
|
|
|
function UpdateCurrentCanvasForEvent(event)
|
|
|
|
{
|
|
|
|
var win = gBrowser.contentWindow;
|
|
|
|
var ctx = gCurrentCanvas.getContext("2d");
|
|
|
|
var scale = gBrowser.markupDocumentViewer.fullZoom;
|
|
|
|
|
|
|
|
var rectList = event.clientRects;
|
|
|
|
for (var i = 0; i < rectList.length; ++i) {
|
|
|
|
var r = rectList[i];
|
|
|
|
// Set left/top/right/bottom to "device pixel" boundaries
|
|
|
|
var left = Math.floor(roundTo(r.left*scale, 0.001))/scale;
|
|
|
|
var top = Math.floor(roundTo(r.top*scale, 0.001))/scale;
|
|
|
|
var right = Math.ceil(roundTo(r.right*scale, 0.001))/scale;
|
|
|
|
var bottom = Math.ceil(roundTo(r.bottom*scale, 0.001))/scale;
|
|
|
|
|
|
|
|
ctx.save();
|
|
|
|
ctx.scale(scale, scale);
|
|
|
|
ctx.translate(left, top);
|
|
|
|
ctx.drawWindow(win, left + win.scrollX, top + win.scrollY,
|
|
|
|
right - left, bottom - top,
|
2009-10-16 03:55:49 -07:00
|
|
|
"rgb(255,255,255)",
|
|
|
|
ctx.DRAWWINDOW_DRAW_CARET);
|
2009-01-05 17:15:13 -08:00
|
|
|
ctx.restore();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
function DocumentLoaded()
|
|
|
|
{
|
2008-04-29 17:39:45 -07:00
|
|
|
// Keep track of which test was slowest, and how long it took.
|
|
|
|
var currentTestRunTime = Date.now() - gCurrentTestStartTime;
|
|
|
|
if (currentTestRunTime > gSlowestTestTime) {
|
|
|
|
gSlowestTestTime = currentTestRunTime;
|
2008-12-07 16:48:36 -08:00
|
|
|
gSlowestTestURL = gCurrentURL;
|
2008-04-29 17:39:45 -07:00
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
clearTimeout(gFailureTimeout);
|
2008-10-19 13:27:46 -07:00
|
|
|
gFailureReason = null;
|
2009-02-08 10:28:30 -08:00
|
|
|
gFailureTimeout = null;
|
2007-08-02 19:28:55 -07:00
|
|
|
|
2009-08-20 00:56:22 -07:00
|
|
|
// Not 'const ...' because of 'EXPECTED_*' value dependency.
|
|
|
|
var outputs = {};
|
|
|
|
const randomMsg = "(EXPECTED RANDOM)";
|
|
|
|
outputs[EXPECTED_PASS] = {
|
|
|
|
true: {s: "TEST-PASS" , n: "Pass"},
|
|
|
|
false: {s: "TEST-UNEXPECTED-FAIL" , n: "UnexpectedFail"}
|
|
|
|
};
|
|
|
|
outputs[EXPECTED_FAIL] = {
|
|
|
|
true: {s: "TEST-UNEXPECTED-PASS" , n: "UnexpectedPass"},
|
|
|
|
false: {s: "TEST-KNOWN-FAIL" , n: "KnownFail"}
|
|
|
|
};
|
|
|
|
outputs[EXPECTED_RANDOM] = {
|
|
|
|
true: {s: "TEST-PASS" + randomMsg , n: "Random"},
|
|
|
|
false: {s: "TEST-KNOWN-FAIL" + randomMsg, n: "Random"}
|
|
|
|
};
|
|
|
|
var output;
|
|
|
|
|
|
|
|
if (gURLs[0].type == TYPE_LOAD) {
|
2008-12-02 04:35:24 -08:00
|
|
|
++gTestResults.LoadOnly;
|
2008-10-19 13:27:46 -07:00
|
|
|
dump("REFTEST TEST-PASS | " + gURLs[0].prettyPath + " | (LOAD ONLY)\n");
|
2009-01-08 13:50:21 -08:00
|
|
|
FinishTestItem();
|
2007-10-03 14:27:04 -07:00
|
|
|
return;
|
|
|
|
}
|
2009-08-20 00:56:22 -07:00
|
|
|
if (gURLs[0].type == TYPE_SCRIPT) {
|
|
|
|
var missing_msg = false;
|
|
|
|
var testwindow = gBrowser.contentWindow;
|
|
|
|
expected = gURLs[0].expected;
|
|
|
|
|
|
|
|
if (testwindow.wrappedJSObject)
|
|
|
|
testwindow = testwindow.wrappedJSObject;
|
|
|
|
|
|
|
|
var testcases;
|
|
|
|
|
|
|
|
if (!testwindow.getTestCases || typeof testwindow.getTestCases != "function") {
|
|
|
|
// Force an unexpected failure to alert the test author to fix the test.
|
|
|
|
expected = EXPECTED_PASS;
|
|
|
|
missing_msg = "test must provide a function getTestCases(). (SCRIPT)\n";
|
|
|
|
}
|
|
|
|
else if (!(testcases = testwindow.getTestCases())) {
|
|
|
|
// Force an unexpected failure to alert the test author to fix the test.
|
|
|
|
expected = EXPECTED_PASS;
|
|
|
|
missing_msg = "test's getTestCases() must return an Array-like Object. (SCRIPT)\n";
|
|
|
|
}
|
|
|
|
else if (testcases.length == 0) {
|
|
|
|
// This failure may be due to a JavaScript Engine bug causing
|
|
|
|
// early termination of the test.
|
|
|
|
missing_msg = "No test results reported. (SCRIPT)\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (missing_msg) {
|
|
|
|
output = outputs[expected][false];
|
|
|
|
++gTestResults[output.n];
|
|
|
|
var result = "REFTEST " + output.s + " | " +
|
|
|
|
gURLs[0].prettyPath + " | " + // the URL being tested
|
|
|
|
missing_msg;
|
|
|
|
|
|
|
|
dump(result);
|
|
|
|
FinishTestItem();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var results = testcases.map(function(test) {
|
|
|
|
return { passed: test.testPassed(), description: test.testDescription()};
|
|
|
|
});
|
|
|
|
var anyFailed = results.some(function(result) { return !result.passed; });
|
|
|
|
var outputPair;
|
|
|
|
if (anyFailed && expected == EXPECTED_FAIL) {
|
|
|
|
// If we're marked as expected to fail, and some (but not all) tests
|
|
|
|
// passed, treat those tests as though they were marked random
|
|
|
|
// (since we can't tell whether they were really intended to be
|
|
|
|
// marked failing or not).
|
|
|
|
outputPair = { true: outputs[EXPECTED_RANDOM][true],
|
|
|
|
false: outputs[expected][false] };
|
|
|
|
} else {
|
|
|
|
outputPair = outputs[expected];
|
|
|
|
}
|
|
|
|
var index = 0;
|
|
|
|
results.forEach(function(result) {
|
|
|
|
var output = outputPair[result.passed];
|
|
|
|
|
|
|
|
++gTestResults[output.n];
|
|
|
|
result = "REFTEST " + output.s + " | " +
|
|
|
|
gURLs[0].prettyPath + " | " + // the URL being tested
|
|
|
|
result.description + " item " + (++index) + "\n";
|
|
|
|
dump(result);
|
|
|
|
});
|
|
|
|
|
|
|
|
FinishTestItem();
|
|
|
|
return;
|
|
|
|
}
|
2007-10-03 14:27:04 -07:00
|
|
|
|
2008-12-16 18:15:38 -08:00
|
|
|
if (gURICanvases[gCurrentURL]) {
|
2009-01-05 17:15:13 -08:00
|
|
|
gCurrentCanvas = gURICanvases[gCurrentURL];
|
|
|
|
} else if (gCurrentCanvas == null) {
|
|
|
|
InitCurrentCanvasWithSnapshot();
|
2008-12-07 16:48:36 -08:00
|
|
|
}
|
2008-12-16 18:15:38 -08:00
|
|
|
if (gState == 1) {
|
2009-01-05 17:15:13 -08:00
|
|
|
gCanvas1 = gCurrentCanvas;
|
2008-12-07 16:48:36 -08:00
|
|
|
} else {
|
2009-01-05 17:15:13 -08:00
|
|
|
gCanvas2 = gCurrentCanvas;
|
2008-12-07 16:48:36 -08:00
|
|
|
}
|
2009-01-05 17:15:13 -08:00
|
|
|
gCurrentCanvas = null;
|
2008-10-15 13:49:42 -07:00
|
|
|
|
|
|
|
resetZoom();
|
2007-08-02 19:28:55 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
switch (gState) {
|
2008-12-16 18:15:38 -08:00
|
|
|
case 1:
|
2007-08-02 19:28:55 -07:00
|
|
|
// First document has been loaded.
|
|
|
|
// Proceed to load the second document.
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2008-12-16 18:15:38 -08:00
|
|
|
StartCurrentURI(2);
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
2008-12-16 18:15:38 -08:00
|
|
|
case 2:
|
2007-03-22 10:30:00 -07:00
|
|
|
// Both documents have been loaded. Compare the renderings and see
|
|
|
|
// if the comparison result matches the expected result specified
|
|
|
|
// in the manifest.
|
2007-08-02 19:28:55 -07:00
|
|
|
|
|
|
|
// number of different pixels
|
|
|
|
var differences;
|
2007-03-22 10:30:00 -07:00
|
|
|
// whether the two renderings match:
|
2007-08-02 19:28:55 -07:00
|
|
|
var equal;
|
|
|
|
|
2008-12-02 17:34:07 -08:00
|
|
|
if (gWindowUtils) {
|
2008-12-16 18:15:38 -08:00
|
|
|
differences = gWindowUtils.compareCanvases(gCanvas1, gCanvas2, {});
|
2007-08-02 19:28:55 -07:00
|
|
|
equal = (differences == 0);
|
|
|
|
} else {
|
|
|
|
differences = -1;
|
2008-12-16 18:15:38 -08:00
|
|
|
var k1 = gCanvas1.toDataURL();
|
|
|
|
var k2 = gCanvas2.toDataURL();
|
2007-08-02 19:28:55 -07:00
|
|
|
equal = (k1 == k2);
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// whether the comparison result matches what is in the manifest
|
2009-08-20 00:56:22 -07:00
|
|
|
var test_passed = (equal == (gURLs[0].type == TYPE_REFTEST_EQUAL));
|
2007-03-22 10:30:00 -07:00
|
|
|
// what is expected on this platform (PASS, FAIL, or RANDOM)
|
|
|
|
var expected = gURLs[0].expected;
|
2009-08-20 00:56:22 -07:00
|
|
|
output = outputs[expected][test_passed];
|
|
|
|
|
|
|
|
++gTestResults[output.n];
|
2009-05-14 07:17:45 -07:00
|
|
|
|
2009-08-20 00:56:22 -07:00
|
|
|
var result = "REFTEST " + output.s + " | " +
|
2008-12-02 04:35:24 -08:00
|
|
|
gURLs[0].prettyPath + " | "; // the URL being tested
|
2009-08-20 00:56:22 -07:00
|
|
|
if (gURLs[0].type == TYPE_REFTEST_NOTEQUAL) {
|
2007-03-22 10:30:00 -07:00
|
|
|
result += "(!=) ";
|
|
|
|
}
|
|
|
|
dump(result + "\n");
|
2008-12-02 04:35:24 -08:00
|
|
|
|
2007-11-26 00:36:53 -08:00
|
|
|
if (!test_passed && expected == EXPECTED_PASS ||
|
|
|
|
test_passed && expected == EXPECTED_FAIL) {
|
2007-11-28 08:45:02 -08:00
|
|
|
if (!equal) {
|
2008-12-16 18:15:38 -08:00
|
|
|
dump("REFTEST IMAGE 1 (TEST): " + gCanvas1.toDataURL() + "\n");
|
|
|
|
dump("REFTEST IMAGE 2 (REFERENCE): " + gCanvas2.toDataURL() + "\n");
|
2007-11-26 00:36:53 -08:00
|
|
|
dump("REFTEST number of differing pixels: " + differences + "\n");
|
|
|
|
} else {
|
2008-12-16 18:15:38 -08:00
|
|
|
dump("REFTEST IMAGE: " + gCanvas1.toDataURL() + "\n");
|
2007-11-26 00:36:53 -08:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2008-12-16 18:15:38 -08:00
|
|
|
UpdateCanvasCache(gURLs[0].url1, gCanvas1);
|
|
|
|
UpdateCanvasCache(gURLs[0].url2, gCanvas2);
|
2008-12-07 16:48:36 -08:00
|
|
|
|
2009-01-08 13:50:21 -08:00
|
|
|
FinishTestItem();
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
default:
|
2007-07-18 14:32:50 -07:00
|
|
|
throw "Unexpected state.";
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function LoadFailed()
|
|
|
|
{
|
2009-02-08 10:28:30 -08:00
|
|
|
gFailureTimeout = null;
|
2008-12-02 04:35:24 -08:00
|
|
|
++gTestResults.FailedLoad;
|
2008-07-15 22:47:12 -07:00
|
|
|
dump("REFTEST TEST-UNEXPECTED-FAIL | " +
|
2008-10-19 13:27:46 -07:00
|
|
|
gURLs[0]["url" + gState].spec + " | " + gFailureReason + "\n");
|
2009-01-08 13:50:21 -08:00
|
|
|
FinishTestItem();
|
|
|
|
}
|
|
|
|
|
|
|
|
function FinishTestItem()
|
|
|
|
{
|
2009-02-10 14:05:27 -08:00
|
|
|
// Replace document with BLANK_URL_FOR_CLEARING in case there are
|
2009-01-08 13:50:21 -08:00
|
|
|
// assertions when unloading.
|
2010-01-18 15:00:16 -08:00
|
|
|
dump("REFTEST INFO | Loading a blank page\n");
|
2009-01-08 13:50:21 -08:00
|
|
|
gClearingForAssertionCheck = true;
|
2009-02-10 14:05:27 -08:00
|
|
|
gBrowser.loadURI(BLANK_URL_FOR_CLEARING);
|
2009-01-08 13:50:21 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
function DoAssertionCheck()
|
|
|
|
{
|
|
|
|
gClearingForAssertionCheck = false;
|
|
|
|
|
2009-01-13 11:50:40 -08:00
|
|
|
if (gDebug.isDebugBuild) {
|
2009-12-12 22:22:52 -08:00
|
|
|
var newAssertionCount = gDebug.assertionCount;
|
2009-01-13 11:50:40 -08:00
|
|
|
var numAsserts = newAssertionCount - gAssertionCount;
|
|
|
|
gAssertionCount = newAssertionCount;
|
|
|
|
|
|
|
|
var minAsserts = gURLs[0].minAsserts;
|
|
|
|
var maxAsserts = gURLs[0].maxAsserts;
|
|
|
|
|
|
|
|
var expectedAssertions = "expected " + minAsserts;
|
|
|
|
if (minAsserts != maxAsserts) {
|
|
|
|
expectedAssertions += " to " + maxAsserts;
|
|
|
|
}
|
|
|
|
expectedAssertions += " assertions";
|
|
|
|
|
|
|
|
if (numAsserts < minAsserts) {
|
|
|
|
++gTestResults.AssertionUnexpectedFixed;
|
2010-05-21 13:17:58 -07:00
|
|
|
dump("REFTEST TEST-UNEXPECTED-PASS | " + gURLs[0].prettyPath +
|
2009-01-13 11:50:40 -08:00
|
|
|
" | assertion count " + numAsserts + " is less than " +
|
|
|
|
expectedAssertions + "\n");
|
|
|
|
} else if (numAsserts > maxAsserts) {
|
|
|
|
++gTestResults.AssertionUnexpected;
|
2010-05-21 13:17:58 -07:00
|
|
|
dump("REFTEST TEST-UNEXPECTED-FAIL | " + gURLs[0].prettyPath +
|
2009-01-13 11:50:40 -08:00
|
|
|
" | assertion count " + numAsserts + " is more than " +
|
|
|
|
expectedAssertions + "\n");
|
|
|
|
} else if (numAsserts != 0) {
|
|
|
|
++gTestResults.AssertionKnown;
|
|
|
|
dump("REFTEST TEST-KNOWN-FAIL | " + gURLs[0].prettyPath +
|
|
|
|
" | assertion count " + numAsserts + " matches " +
|
|
|
|
expectedAssertions + "\n");
|
|
|
|
}
|
2009-01-08 13:50:21 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
// And start the next test.
|
2007-03-22 10:30:00 -07:00
|
|
|
gURLs.shift();
|
|
|
|
StartCurrentTest();
|
|
|
|
}
|