Skip to content

onmessage function is not being called, causing timeout when defined. #37

@ijonas

Description

@ijonas

Hi,

I've been playing with Sandbox on node 0.10.33 on OSX. I can send message from inside the Sandbox out the host environment. When I try and postMessage() into the Sandbox and with an onmessage function defined, the run() method times out.

Here's my code

var Sandbox = require('sandbox');

sb = new Sandbox();
sb.on('message', function (message) { 
  console.log("outer message handler: "+message); 
});
sb.on('ready', function() { 
  console.log('ready. posting...'); 
  sb.postMessage("calling when ready"); 
});
sb.run("postMessage('message from inside'); 10 + 10;", function(output) { 
  console.log(output) 
});



sb = new Sandbox();
sb.on('message', function (message) { 
  console.log("outer message handler: "+message); 
});
sb.on('ready', function() { 
  console.log('ready. posting...'); 
  sb.postMessage("calling when ready"); 
});
sb.run("onmessage = function (msg) { console.log(msg); };", function(output) { 
  console.log(output) 
});

Producing the following output:

outer message handler: message from inside
ready. posting...
{ result: '20', console: [] }
ready. posting...
{ result: 'TimeoutError', console: [] }    

Is anyone else seeing this problem? I've run the test code and it passes on my machine. If I modify the test code by removing the spies, then the same timeout problem occurs.

A little help appreciated,
Ijonas.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions