Skip to content

Commit

Permalink
Retooling to be IE11-compatible and streamline tests to avoid the unl…
Browse files Browse the repository at this point in the history
…oad issues, see phetsims/aqua#88
  • Loading branch information
jonathanolson committed Apr 25, 2020
1 parent 3448b9e commit b6b92f9
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions js/initialize-globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,15 @@
*/
buildCompatible: { type: 'flag' },

/**
* When provided a non-zero-length value, the sim will send out assorted events meant for continus testing
* integration (see sim-test.js).
*/
continuousTest: {
type: 'string',
defaultValue: ''
},

/**
* The color profile used at startup, relevant only for sims that support multiple color profiles.
* Such sims are required to have a 'default' profile. If a sim supports a 'projector mode' then
Expand Down Expand Up @@ -758,6 +767,49 @@
window.assertions.enableAssertSlow();
}

/**
* Sends a message to a continuous testing container.
* @public
*
* @param {Object} [options] - Specific object results sent to CT.
*/
window.phet.chipper.reportContinuousTestResult = options => {
window.parent && window.parent.postMessage( JSON.stringify( _.extend( {
continuousTest: JSON.parse( phet.chipper.queryParameters.continuousTest ),
url: window.location.href
}, options ) ), '*' );
};

if ( phet.chipper.queryParameters.continuousTest ) {
window.addEventListener( 'error', function( a ) {
let message = '';
let stack = '';
if ( a && a.message ) {
message = a.message;
}
if ( a && a.error && a.error.stack ) {
stack = a.error.stack;
}
phet.chipper.reportContinuousTestResult( {
type: 'continuous-test-error',
message: message,
stack: stack
} );
} );
window.addEventListener( 'beforeunload', function( e ) {
phet.chipper.reportContinuousTestResult( {
type: 'continuous-test-unload'
} );
} );
// window.open stub. otherwise we get tons of "Report Problem..." popups that stall
window.open = () => {
return {
focus: () => {},
blur: () => {}
};
};
}

// Communicate sim errors to joist/tests/test-sims.html
if ( phet.chipper.queryParameters.postMessageOnError ) {
window.addEventListener( 'error', function( a ) {
Expand Down

0 comments on commit b6b92f9

Please sign in to comment.