File tree 2 files changed +15
-0
lines changed
2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -198,6 +198,10 @@ class Frame extends EventEmitter {
198
198
// 2. Identify the app the message came from.
199
199
if ( this . iframe . contentWindow !== event . source ) return ;
200
200
201
+ // For Chrome, the origin property is in the event.originalEvent object.
202
+ // Update origin so it can be used to post back to this frame.
203
+ this . origin = event . origin || event . originalEvent . origin ;
204
+
201
205
logger . log ( '<< consumer' , event . origin , event . data ) ;
202
206
203
207
// 3. Send a response, if any, back to the app.
Original file line number Diff line number Diff line change @@ -145,6 +145,17 @@ describe('Frame', () => {
145
145
sinon . assert . called ( handle ) ;
146
146
} ) ;
147
147
148
+ it ( "updates the app's origin to match the frame's origin" , ( ) => {
149
+ const event = {
150
+ data : { jsonrpc : '2.0' } ,
151
+ source : frame . iframe . contentWindow ,
152
+ origin : 'http://localhost:8080'
153
+ } ;
154
+ frame . handleProviderMessage ( event ) ;
155
+
156
+ expect ( frame . origin ) . to . equal ( event . origin ) ;
157
+ } ) ;
158
+
148
159
it ( "calls this.JSONRPC.handle with the data of given event" , ( ) => {
149
160
const event = {
150
161
data : { jsonrpc : '2.0' } ,
You can’t perform that action at this time.
0 commit comments