gecko/content/canvas/test/webgl/undo-r15330-async-test-list-loading.patch
Benoit Jacob 8eeed3c374 Bug 694730 - Upgrade WebGL conformance test suite to r15815 - no review
The 1.0.1 release is really close, and upgrading now allows us to give feedback and make sure that all tests are passable.

The canonical URL for this test suite is
  https://cvs.khronos.org/svn/repos/registry/trunk/public/webgl/sdk/tests/webgl-conformance-tests.html

--HG--
rename : content/canvas/test/webgl/conformance/include.vs => content/canvas/test/webgl/conformance/glsl/misc/include.vs
2011-10-16 21:19:28 -04:00

237 lines
7.0 KiB
Diff

# HG changeset patch
# Parent 0e44920c4e5e697f86e0a42b909c5a032d70a1a4
diff --git a/content/canvas/test/webgl/resources/webgl-test-harness.js b/content/canvas/test/webgl/resources/webgl-test-harness.js
--- a/content/canvas/test/webgl/resources/webgl-test-harness.js
+++ b/content/canvas/test/webgl/resources/webgl-test-harness.js
@@ -90,190 +90,105 @@ var log = function(msg) {
if (window.console && window.console.log) {
window.console.log(msg);
}
};
/**
* Loads text from an external file. This function is synchronous.
* @param {string} url The url of the external file.
- * @param {!function(bool, string): void} callback that is sent a bool for
- * success and the string.
+ * @return {string} the loaded text if the request is synchronous.
*/
-var loadTextFileAsynchronous = function(url, callback) {
- log ("loading: " + url);
+var loadTextFileSynchronous = function(url) {
var error = 'loadTextFileSynchronous failed to load url "' + url + '"';
var request;
if (window.XMLHttpRequest) {
request = new XMLHttpRequest();
if (request.overrideMimeType) {
request.overrideMimeType('text/plain');
}
} else {
throw 'XMLHttpRequest is disabled';
}
- try {
- request.open('GET', url, true);
- request.onreadystatechange = function() {
- if (request.readyState == 4) {
- var text = '';
- // HTTP reports success with a 200 status. The file protocol reports
- // success with zero. HTTP does not use zero as a status code (they
- // start at 100).
- // https://developer.mozilla.org/En/Using_XMLHttpRequest
- var success = request.status == 200 || request.status == 0;
- if (success) {
- text = request.responseText;
- }
- log("loaded: " + url);
- callback(success, text);
- }
- };
- request.send(null);
- } catch (e) {
- log("failed to load: " + url);
- callback(false, '');
+ request.open('GET', url, false);
+ request.send(null);
+ if (request.readyState != 4) {
+ throw error;
}
+ return request.responseText;
};
-var getFileList = function(url, callback) {
+var getFileList = function(url) {
var files = [];
-
- var getFileListImpl = function(url, callback) {
- var files = [];
- if (url.substr(url.length - 4) == '.txt') {
- loadTextFileAsynchronous(url, function() {
- return function(success, text) {
- if (!success) {
- callback(false, '');
- return;
- }
- var lines = text.split('\n');
- var prefix = '';
- var lastSlash = url.lastIndexOf('/');
- if (lastSlash >= 0) {
- prefix = url.substr(0, lastSlash + 1);
- }
- var fail = false;
- var count = 1;
- var index = 0;
- for (var ii = 0; ii < lines.length; ++ii) {
- var str = lines[ii].replace(/^\s\s*/, '').replace(/\s\s*$/, '');
- if (str.length > 4 &&
- str[0] != '#' &&
- str[0] != ";" &&
- str.substr(0, 2) != "//") {
- new_url = prefix + str;
- ++count;
- getFileListImpl(new_url, function(index) {
- return function(success, new_files) {
- log("got files: " + new_files.length);
- if (success) {
- files[index] = new_files;
- }
- finish(success);
- };
- }(index++));
- }
- }
- finish(true);
-
- function finish(success) {
- if (!success) {
- fail = true;
- }
- --count;
- log("count: " + count);
- if (!count) {
- callback(!fail, files);
- }
- }
- }
- }());
-
- } else {
- files.push(url);
- callback(true, files);
+ if (url.substr(url.length - 4) == '.txt') {
+ var lines = loadTextFileSynchronous(url).split('\n');
+ var prefix = '';
+ var lastSlash = url.lastIndexOf('/');
+ if (lastSlash >= 0) {
+ prefix = url.substr(0, lastSlash + 1);
}
- };
-
- getFileListImpl(url, function(success, files) {
- // flatten
- var flat = [];
- flatten(files);
- function flatten(files) {
- for (var ii = 0; ii < files.length; ++ii) {
- var value = files[ii];
- if (typeof(value) == "string") {
- flat.push(value);
- } else {
- flatten(value);
- }
+ for (var ii = 0; ii < lines.length; ++ii) {
+ var str = lines[ii].replace(/^\s\s*/, '').replace(/\s\s*$/, '');
+ if (str.length > 4 &&
+ str[0] != '#' &&
+ str[0] != ";" &&
+ str.substr(0, 2) != "//") {
+ new_url = prefix + str;
+ files = files.concat(getFileList(new_url));
}
}
- callback(success, flat);
- });
-};
+ } else {
+ files.push(url);
+ }
+ return files;
+}
var TestFile = function(url) {
this.url = url;
};
var TestHarness = function(iframe, filelistUrl, reportFunc) {
this.window = window;
this.iframe = iframe;
this.reportFunc = reportFunc;
- this.timeoutDelay = 20000;
- this.files = [];
-
- var that = this;
- getFileList(filelistUrl, function() {
- return function(success, files) {
- that.addFiles_(success, files);
- };
- }());
-
-};
-
-TestHarness.reportType = {
- ADD_PAGE: 1,
- READY: 2,
- START_PAGE: 3,
- TEST_RESULT: 4,
- FINISH_PAGE: 5,
- FINISHED_ALL_TESTS: 6
-};
-
-TestHarness.prototype.addFiles_ = function(success, files) {
- if (!success) {
+ try {
+ var files = getFileList(filelistUrl);
+ } catch (e) {
this.reportFunc(
TestHarness.reportType.FINISHED_ALL_TESTS,
'Unable to load tests. Are you running locally?\n' +
'You need to run from a server or configure your\n' +
'browser to allow access to local files (not recommended).\n\n' +
'Note: An easy way to run from a server:\n\n' +
'\tcd path_to_tests\n' +
'\tpython -m SimpleHTTPServer\n\n' +
'then point your browser to ' +
'<a href="http://localhost:8000/webgl-conformance-tests.html">' +
'http://localhost:8000/webgl-conformance-tests.html</a>',
false)
return;
}
- log("total files: " + files.length);
+ this.files = [];
for (var ii = 0; ii < files.length; ++ii) {
- log("" + ii + ": " + files[ii]);
this.files.push(new TestFile(files[ii]));
this.reportFunc(TestHarness.reportType.ADD_PAGE, files[ii], undefined);
}
- this.reportFunc(TestHarness.reportType.READY, undefined, undefined);
this.nextFileIndex = files.length;
this.lastFileIndex = files.length;
+ this.timeoutDelay = 20000;
}
+TestHarness.reportType = {
+ ADD_PAGE: 1,
+ START_PAGE: 2,
+ TEST_RESULT: 3,
+ FINISH_PAGE: 4,
+ FINISHED_ALL_TESTS: 5
+};
+
TestHarness.prototype.runTests = function(opt_start, opt_count) {
var count = opt_count || this.files.length;
this.nextFileIndex = opt_start || 0;
this.lastFileIndex = this.nextFileIndex + count;
this.startNextFile();
};
TestHarness.prototype.setTimeout = function() {