THESE TESTS ARE DEPRECATED IN FAVOR OF THE WEBGL TESTS
Please see the official WebGL test suite.
I'm not going to port these tests over to the WebGL test harness (programming does not align with my happiness vector right now, and has never aligned with my financial well-being vector). But if You, Dear Reader, have such fire and gusto burning in your bright beacon of a mind as to undertake the task, feel free to nick whatever you deem useful.
Tests for the WebGL canvas context
These tests are intended to serve the following purposes:
- Assert spec conformance
- Check the safety of the GL binding (bounds checking, same origin policy)
- Provide performance numbers for developers
Running the tests
- Install a browser with WebGL support
ruby gen_tests.rbif you have modified the tests.
ruby test_server.rbif you want to get test run output to test_server's stdout (especially useful for finding out which test crashed your browser.)
- Open all_tests.html in your browser.
Want to contribute?
- Fork this repo
- Look into templates/ to see which functions lack tests (also see methods.txt and nsICanvasRenderingContextWebGL.idl):
- copy methodName.html to functions/methodName.html and write tests that test the results of valid inputs.
- copy methodNameBadArgs.html to functions/methodNameBadArgs.html and write tests to assert that invalid inputs throw exceptions.
- If your test causes a segfault, add the following to the top of the script tag:
Tests.autorun = false; Tests.message = "Caution: this may crash your browser";
- For each performance test:
- Write a performance/myTestName.html and set
Tests.autorun = false;
- If you have a test that you would like to run over the whole API or want to generate tests programmatically, add them to gen_tests.rb or write your own script.
- Create a commit for each file. (E.g.
for f in $(git status | grep -e "^#\sfunctions/\S$" | sed "s/^#\s*//"); do git add $f; git commit -m $f; done)
- Send me a pull request.
- Congratulations, you're now a contributor!
For more information on WebGL:
What's the stuff in apigen?
There are some Python scripts in the apigen/ directory that generate C++ based on the API definition files (gl2.h, api_modifications.txt, valid_args.txt.) The generated code is Mozilla XPCOM functions that check their args against the valid GLES 2.0 constants (as they were written on the man pages.) There's also some wackier stuff for checking copyTexImage2D and copyTexSubImage2D image dimensions against viewport dimensions.
If you can use it to generate code for your WebGL implementation, it might save you 1500 lines of typing and testing. The last time I used it was summer 2009 to generate a patch for Canvas 3D, so it's likely somewhat out of date.