diff --git a/js/impress.js b/js/impress.js index 78d4cbc..7945a56 100644 --- a/js/impress.js +++ b/js/impress.js @@ -2487,21 +2487,13 @@ var init = function( cssConsole, cssIframe ) { if ( ( cssConsole === undefined || cssConsole === cssFileOldDefault ) && ( cssIframe === undefined || cssIframe === cssFileIframeOldDefault ) ) { - window.console.log( 'impressConsole.init() is deprecated. ' + + window.console.log( 'impressConsole().init() is deprecated. ' + 'impressConsole is now initialized automatically when you ' + 'call impress().init().' ); } _init( cssConsole, cssIframe ); }; - document.addEventListener( 'impress:init', function() { - _init(); - - // Add 'P' to the help popup - triggerEvent( document, 'impress:help:add', - { command: 'P', text: 'Presenter console', row: 10 } ); - } ); - // New API for impress.js plugins is based on using events root.addEventListener( 'impress:console:open', function() { window.open(); @@ -2520,11 +2512,21 @@ // Return the object allConsoles[ rootId ] = { init: init, open: open, clockTick: clockTick, - registerKeyEvent: registerKeyEvent }; + registerKeyEvent: registerKeyEvent, _init: _init }; return allConsoles[ rootId ]; }; + // This initializes impressConsole automatically when initializing impress itself + document.addEventListener( 'impress:init', function(event) { + // impressConsole wants the id string, not the DOM element directly + impressConsole(event.target.id)._init(); + + // Add 'P' to the help popup + triggerEvent( document, 'impress:help:add', + { command: 'P', text: 'Presenter console', row: 10 } ); + } ); + // Returns a string to be used inline as a css `; }; - impressConsole(); - } )( document, window ); /** diff --git a/karma.conf-sauce.js b/karma.conf-sauce.js index 4f77ff5..cfaf636 100644 --- a/karma.conf-sauce.js +++ b/karma.conf-sauce.js @@ -55,6 +55,7 @@ module.exports = function( config ) { // The QUnit tests "test/helpers.js", "test/core_tests.js", + "test/non_default.js", "src/plugins/navigation/navigation_tests.js", // Presentation files, for the iframe {pattern: "test/*.html", watched: true, served: true, included: false}, diff --git a/karma.conf.js b/karma.conf.js index 4251687..e51034e 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -18,6 +18,7 @@ module.exports = function( config ) { // The QUnit tests "test/helpers.js", "test/core_tests.js", + "test/non_default.js", "src/plugins/navigation/navigation_tests.js", // Presentation files, for the iframe {pattern: "test/*.html", watched: true, served: true, included: false}, diff --git a/package.json b/package.json index c64701a..44a8606 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "jscs": "2.11.0", "jshint": "2.9.1", "karma": "0.13.22", - "karma-chrome-launcher": "1.0.1", + "karma-chrome-launcher": "2.2.0", "karma-cli": "1.0.0", "karma-firefox-launcher": "~0.1", "karma-qunit": "1.0.0", diff --git a/qunit_test_runner.html b/qunit_test_runner.html index 2087e23..72ec09f 100644 --- a/qunit_test_runner.html +++ b/qunit_test_runner.html @@ -19,6 +19,7 @@ + diff --git a/src/plugins/impressConsole/impressConsole.js b/src/plugins/impressConsole/impressConsole.js index 4a0b207..bbc0691 100644 --- a/src/plugins/impressConsole/impressConsole.js +++ b/src/plugins/impressConsole/impressConsole.js @@ -558,21 +558,13 @@ var init = function( cssConsole, cssIframe ) { if ( ( cssConsole === undefined || cssConsole === cssFileOldDefault ) && ( cssIframe === undefined || cssIframe === cssFileIframeOldDefault ) ) { - window.console.log( 'impressConsole.init() is deprecated. ' + + window.console.log( 'impressConsole().init() is deprecated. ' + 'impressConsole is now initialized automatically when you ' + 'call impress().init().' ); } _init( cssConsole, cssIframe ); }; - document.addEventListener( 'impress:init', function() { - _init(); - - // Add 'P' to the help popup - triggerEvent( document, 'impress:help:add', - { command: 'P', text: 'Presenter console', row: 10 } ); - } ); - // New API for impress.js plugins is based on using events root.addEventListener( 'impress:console:open', function() { window.open(); @@ -591,11 +583,22 @@ // Return the object allConsoles[ rootId ] = { init: init, open: open, clockTick: clockTick, - registerKeyEvent: registerKeyEvent }; + registerKeyEvent: registerKeyEvent, _init: _init }; return allConsoles[ rootId ]; }; + // This initializes impressConsole automatically when initializing impress itself + document.addEventListener( 'impress:init', function( event ) { + + // Note: impressConsole wants the id string, not the DOM element directly + impressConsole( event.target.id )._init(); + + // Add 'P' to the help popup + triggerEvent( document, 'impress:help:add', + { command: 'P', text: 'Presenter console', row: 10 } ); + } ); + // Returns a string to be used inline as a css `; }; - impressConsole(); - } )( document, window ); diff --git a/src/plugins/navigation/navigation_tests.js b/src/plugins/navigation/navigation_tests.js index fd4a05b..bccdabe 100644 --- a/src/plugins/navigation/navigation_tests.js +++ b/src/plugins/navigation/navigation_tests.js @@ -155,8 +155,8 @@ QUnit.test( "Navigation Plugin - No-op tests", function( assert ) { root.addEventListener( "impress:stepleave", assertStepLeaveWrapper ); // These are no-op actions, we're already in step-1 -----------------------// - assert.ok( iframeWin.syn.click( "step-1", {} ), - "Click on step that is currently active, should do nothing." ); + //assert.ok( iframeWin.syn.click( "step-1", {} ), + // "Click on step that is currently active, should do nothing." ); assert.ok( iframeWin.syn.click( "linktofirst", {} ), "Click on link pointing to step that is currently active, should do nothing." ); diff --git a/test/bootstrap.js b/test/bootstrap.js index 774d62f..135fd5f 100644 --- a/test/bootstrap.js +++ b/test/bootstrap.js @@ -3,7 +3,7 @@ // TODO: This is the bootstrap file for *karma*. Poorly named (since karma is // only one option, in this repo) but keeping the same name now to avoid // unnecessary deviation with upstream. -// If you just want to run the tests locally, you can open test/index.html in Firefox. +// If you just want to run the tests locally, you can open /qunit_test_runner.html in Firefox. // That's annoying: karma-qunit doesn't provide the qunit-fixture element // https://github.com/karma-runner/karma-qunit/issues/18 diff --git a/test/helpers.js b/test/helpers.js index 746facd..a1521cc 100644 --- a/test/helpers.js +++ b/test/helpers.js @@ -1,8 +1,13 @@ // This file contains so much HTML, that we will just respectfully disagree about js /* jshint quotmark:single */ -/* global document, console, setTimeout, navigator */ +/* global document, console, setTimeout, navigator, QUnit */ /* exported loadIframe, initPresentation, _impressSupported */ +// Log all QUnit assertions to console.log(), so that they are visible in karma output +QUnit.log( function( details ) { + console.log( 'QUnit.log: ', details.result, details.message ); +} ); + var loadIframe = function( src, assert, callback ) { console.log( 'Begin loadIframe' ); @@ -52,7 +57,7 @@ var loadIframe = function( src, assert, callback ) { iframe.src = src; }; -var initPresentation = function( assert, callback ) { +var initPresentation = function( assert, callback, rootId ) { console.log( 'Begin initPresentation' ); var iframe = document.getElementById( 'presentation-iframe' ); var iframeDoc = iframe.contentDocument; @@ -75,7 +80,7 @@ var initPresentation = function( assert, callback ) { }; iframeDoc.addEventListener( 'impress:stepenter', waitForStepEnterWrapper ); - assert.strictEqual( iframeWin.impress().init(), undefined, 'Initializing impress.' ); + assert.strictEqual( iframeWin.impress( rootId ).init(), undefined, 'Initializing impress.' ); }; // Helper function to determine whether this browser is supported by diff --git a/test/non_default.html b/test/non_default.html new file mode 100644 index 0000000..e484106 --- /dev/null +++ b/test/non_default.html @@ -0,0 +1,18 @@ + + + +
+ +