Improve testing infrastructure.
Don't test video in PhantomJS.  Allow console.log messages to appear in tutorial test output.
MODIFY
tests/tutorials.js
tests/tutorials.js
@@ -25,7 +25,13 @@ describe('tutorials', function () {
var base$, tests;
base$ = $('iframe#map')[0].contentWindow.jQuery;
- /* Find all codeblock_tests. We chain them together and end on the it
+ /* If a codeblock test requires html video and the current browser
+ * doesn't support video, skip the test. */
+ if (!$('iframe#map')[0].contentWindow.HTMLVideoElement && base$('.codeblock[htmlvideo]').length) {
+ done();
+ return;
+ }
+ /* Find all codeblock_tests. We chain them together and end on the
* function's done callback, so reverse them so that they run in the
* order written. */
tests = base$(base$('.codeblock_test').get().reverse());
@@ -36,7 +42,7 @@ describe('tutorials', function () {
testDefer = $.Deferred();
testDefer.then(done);
done = function () {
- /* When the codeblock's target has runm handle the results */
+ /* When the codeblock's target has run, handle the results */
var onCodeLoaded = function () {
var targetWindow = target[0].contentWindow,
tut$ = targetWindow.$,

MODIFY
tutorials/common/index.pug
tutorials/common/index.pug
target: the ID of the iframe element where the code will be executed.
Defaults to 'workframe'. Only one chain of blocks in associated with a
target may be run at a time.
+
+ You can add additional attributes to the codeblock. These include:
+
+ webgl: the associated test requires webgl to be present or mocked
+ htmlvideo: HTMLVideoElements are required, so don't test if they aren't
+ available
mixin codeblock(format, step, parentstep, initial, stepname, target)
-
attributes.format = format || attributes.format || 'javascript';

MODIFY
tutorials/common/tutorials.js
tutorials/common/tutorials.js
@@ -126,11 +126,21 @@ function process_block(selector) {
pos = html.length;
}
if (js) {
- /* If any code block is marked as needing webgl and the current window's
- * parent has a geojs element that reports that it doesn't support webgl,
- * mock webgl. This is expected to only happen in the automated tests. */
- if (webgl && window.parent && window.parent !== window && window.parent.geo && !window.parent.geo.gl.vglRenderer.supported()) {
- js = 'geo.util.mockVGLRenderer();\n' + js;
+ /* If any code block is marked as needing webgl and the current window has
+ * a geojs element that reports that it doesn't support webgl, mock webgl.
+ * This is expected to only happen in the automated tests. */
+ if (webgl && window.parent && window.parent !== window && window.geo && !window.geo.gl.vglRenderer.supported()) {
+ js = 'geo.util.mockVGLRenderer();\n' +
+ js +
+ '\ngeo.util.restoreVGLRenderer();\n';
+ }
+ /* If we are in a test environment, redirect the console to the parent
+ * window to make debugging easier. */
+ if (window.parent && window.parent !== window) {
+ js = 'window.console = window.parent.parent.console;\n' +
+ 'window.parent.console = window.parent.parent.console;\n' +
+ 'console.log("Testing " + window.parent.document.title);\n' +
+ js;
}
html = html.substr(0, pos).replace(/\s+$/, '') + '\n<script type="text/javascript">\n' + js + '</script>\n' + html.substr(pos);
}

Improve testing infrastructure.

Don't test video in PhantomJS.  Allow console.log messages to appear in tutorial test output.