impressConsole broke init() if root element didn't have id="impress"

Also adds regression tests to prevent this from happening in the future
as well as upgrades karma-chrome-launcher to newest version.

Fixes #654
This commit is contained in:
Henrik Ingo
2017-12-31 14:36:43 +02:00
parent cd499ed8cf
commit df3532085f
11 changed files with 202 additions and 31 deletions

View File

@@ -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 <style> element in the console window.
// Apologies for length, but hiding it here at the end to keep it away from rest of the code.
var cssStyleStr = function() {
@@ -742,6 +745,4 @@
</style>`;
};
impressConsole();
} )( document, window );

View File

@@ -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." );