Properly set the origin on websocket messages

This commit is contained in:
Bastien Orivel 2018-08-16 13:32:52 +02:00
parent 89ab110357
commit a1925aab52
6 changed files with 17 additions and 17 deletions

View file

@ -33,7 +33,7 @@ use net_traits::request::{RequestInit, RequestMode};
use profile_traits::ipc as ProfiledIpc;
use script_runtime::CommonScriptMsg;
use script_runtime::ScriptThreadEventCategory::WebSocketEvent;
use servo_url::ServoUrl;
use servo_url::{ImmutableOrigin, ServoUrl};
use std::borrow::ToOwned;
use std::cell::Cell;
use std::ptr;
@ -274,6 +274,10 @@ impl WebSocket {
Ok(true)
}
pub fn origin(&self) -> ImmutableOrigin {
self.url.origin()
}
}
impl WebSocketMethods for WebSocket {
@ -549,7 +553,12 @@ impl TaskOnce for MessageReceivedTask {
}
},
}
MessageEvent::dispatch_jsval(ws.upcast(), &global, message.handle());
MessageEvent::dispatch_jsval(
ws.upcast(),
&global,
message.handle(),
Some(&ws.origin().ascii_serialization())
);
}
}
}