@@ -36,10 +36,12 @@ function processBackgroundIncomingMessage(msg) {
3636}
3737
3838// Function to send a message to main.js
39- function notifyDevtools ( msg ) {
40- console . log ( 'Background.js Sending Message' , msg ) ;
39+ function notifyDevtools ( msgType , msg ) {
40+ var packagedMessage = new Object ( ) ;
41+ packagedMessage . msgType = msgType ;
42+ packagedMessage . msg = msg ;
4143 ports . forEach ( function ( port ) {
42- port . postMessage ( msg ) ;
44+ port . postMessage ( packagedMessage ) ;
4345 } ) ;
4446}
4547
@@ -54,18 +56,19 @@ function getJsonResource(tabID) {
5456 if ( xhr . readyState === 4 && isSolidus ) { // Is complete Solidus response?
5557 if ( xhr . status !== 200 ) { // Check that Solidus response didn't fail
5658 errMsg = 'Failed to get Solidus context. Status: ' + xhr . status ;
57- notifyDevtools ( JSON . parse ( '{" error":"' + errMsg + '"}' ) ) ;
59+ notifyDevtools ( ' error' , errMsg ) ;
5860 } else {
5961 try {
6062 // Send Solidus JSON to devpanel
61- notifyDevtools ( JSON . parse ( xhr . responseText ) ) ;
63+ notifyDevtools ( 'context' , JSON . parse ( xhr . responseText ) ) ;
64+ notifyDevtools ( 'status' , 'The x-powered-by header is' + xhr . getResponseHeader ( 'X-Powered-By' ) ) ;
6265 } catch ( e ) {
63- notifyDevtools ( JSON . parse ( '{" error":"' + e + '"}' ) ) ;
66+ notifyDevtools ( ' error' , e ) ;
6467 }
6568 }
6669 } else {
6770 errMsg = 'Looks like you\'re not inspecting a Solidus Page.' ;
68- notifyDevtools ( JSON . parse ( '{" error":"' + errMsg + '"}' ) ) ;
71+ notifyDevtools ( ' error' , errMsg ) ;
6972 }
7073 } ;
7174 xhr . send ( ) ;
0 commit comments