Skip to content

Commit

Permalink
Fixed logic for checking for the existence of a (non-self) parent win…
Browse files Browse the repository at this point in the history
…dow, see phetsims/tasks#958
  • Loading branch information
samreid committed Nov 19, 2018
1 parent e7e5ba8 commit d961dad
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions js/pageload-connector.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
if ( data && data.error && data.error.stack ) {
stack = data.error.stack;
}
window.parent && window.parent.postMessage( JSON.stringify( {
( window.parent !== window.top ) && window.parent.postMessage( JSON.stringify( {
type: 'pageload-error',
url: window.location.href,
message: message,
Expand All @@ -35,7 +35,7 @@
// Wait 4 seconds before reporting load, to see if it errors first
setTimeout( function() {
if ( !hasErrored ) {
window.parent && window.parent.postMessage( JSON.stringify( {
( window.parent !== window.top ) && window.parent.postMessage( JSON.stringify( {
type: 'pageload-load',
url: window.location.href
} ), '*' );
Expand Down
4 changes: 2 additions & 2 deletions js/qunit-connector.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
QUnit.config.autostart = false;

QUnit.log( function( details ) {
window.parent && window.parent.postMessage( JSON.stringify( {
( window.parent !== window.top ) && window.parent.postMessage( JSON.stringify( {
type: 'qunit-test',
main: details.module, // TODO: what is this for?
result: details.result,
Expand All @@ -25,7 +25,7 @@
} );

QUnit.on( 'runEnd', function( data ) {
window.parent && window.parent.postMessage( JSON.stringify( {
( window.parent !== window.top ) && window.parent.postMessage( JSON.stringify( {
type: 'qunit-done',
failed: data.testCounts.failed,
passed: data.testCounts.passed,
Expand Down
6 changes: 3 additions & 3 deletions js/snapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ function handleFrame() {
var hashedURL = hash( url );
console.log( count, hashedURL );

window.parent && window.parent.postMessage( JSON.stringify( {
( window.parent !== window.top ) && window.parent.postMessage( JSON.stringify( {
type: 'screenshot',
number: count - 1,
url: url,
Expand All @@ -156,7 +156,7 @@ function handleFrame() {
if ( count === options.numFrames ) {
var fullHash = hash( screenshotHashes );

window.parent && window.parent.postMessage( JSON.stringify( {
( window.parent !== window.top ) && window.parent.postMessage( JSON.stringify( {
type: 'snapshot',
hash: fullHash,
url: window.location.href
Expand All @@ -179,7 +179,7 @@ window.addEventListener( 'error', function( a ) {
if ( a && a.error && a.error.stack ) {
stack = a.error.stack;
}
window.parent && window.parent.postMessage( JSON.stringify( {
( window.parent !== window.top ) && window.parent.postMessage( JSON.stringify( {
type: 'error',
message: message,
stack: stack
Expand Down
2 changes: 1 addition & 1 deletion js/test-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ window.aqua = {
* @param {Object} message
*/
sendMessage: function( message ) {
window.parent && window.parent.postMessage( JSON.stringify( message ), '*' );
( window.parent !== window.top ) && window.parent.postMessage( JSON.stringify( message ), '*' );
},

/**
Expand Down

0 comments on commit d961dad

Please sign in to comment.