Implement dissimilar-origin postMessage.

This commit is contained in:
Alan Jeffrey 2017-02-14 16:06:28 -06:00
parent f5c67fda04
commit f9c5d0c117
12 changed files with 191 additions and 13 deletions

View file

@ -718,10 +718,7 @@ impl WindowMethods for Window {
let data = try!(StructuredCloneData::write(cx, message));
// Step 9.
let runnable = PostMessageHandler::new(self, origin, data);
let msg = CommonScriptMsg::RunnableMsg(ScriptThreadEventCategory::DomEvent, box runnable);
// TODO(#12718): Use the "posted message task source".
let _ = self.script_chan.send(msg);
self.post_message(origin, data);
Ok(())
}
@ -1910,3 +1907,12 @@ impl Runnable for PostMessageHandler {
message.handle());
}
}
impl Window {
pub fn post_message(&self, origin: Option<ImmutableOrigin>, data: StructuredCloneData) {
let runnable = PostMessageHandler::new(self, origin, data);
let msg = CommonScriptMsg::RunnableMsg(ScriptThreadEventCategory::DomEvent, box runnable);
// TODO(#12718): Use the "posted message task source".
let _ = self.script_chan.send(msg);
}
}