aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2017-04-24 08:54:07 -0500
committerGitHub <noreply@github.com>2017-04-24 08:54:07 -0500
commit4263b798ad3969ceeb86e607d5f13eeadd2db6dd (patch)
tree197bf2669339e57fd09e123ce80f67411fb6a981
parent46bb635c4c1eb9e420392d7a761956c1cc10ce3a (diff)
parent2c6bd51bef60ebcb03b762f4b84627133e595fa0 (diff)
downloadservo-4263b798ad3969ceeb86e607d5f13eeadd2db6dd.tar.gz
servo-4263b798ad3969ceeb86e607d5f13eeadd2db6dd.zip
Auto merge of #16592 - avadacatavra:globalscope, r=jdm
added origin to globalscope <!-- Please describe your changes on the following line: --> Replaces #16561 --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [ ] These changes fix #__ (github issue number if applicable). <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because _____ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16592) <!-- Reviewable:end -->
-rw-r--r--components/script/dom/dissimilaroriginlocation.rs5
-rw-r--r--components/script/dom/dissimilaroriginwindow.rs8
-rw-r--r--components/script/dom/globalscope.rs14
-rw-r--r--components/script/dom/location.rs6
-rw-r--r--components/script/dom/window.rs10
-rw-r--r--components/script/dom/workerglobalscope.rs6
-rw-r--r--components/script/script_thread.rs1
-rw-r--r--components/script_traits/lib.rs2
8 files changed, 44 insertions, 8 deletions
diff --git a/components/script/dom/dissimilaroriginlocation.rs b/components/script/dom/dissimilaroriginlocation.rs
index b4cd2d84e5d..d3aec5c90ee 100644
--- a/components/script/dom/dissimilaroriginlocation.rs
+++ b/components/script/dom/dissimilaroriginlocation.rs
@@ -12,6 +12,7 @@ use dom::bindings::str::DOMString;
use dom::bindings::str::USVString;
use dom::dissimilaroriginwindow::DissimilarOriginWindow;
use dom_struct::dom_struct;
+use servo_url::MutableOrigin;
/// Represents a dissimilar-origin `Location` that exists in another script thread.
///
@@ -43,6 +44,10 @@ impl DissimilarOriginLocation {
window,
DissimilarOriginLocationBinding::Wrap)
}
+
+ pub fn origin(&self) -> &MutableOrigin {
+ self.window.origin()
+ }
}
impl DissimilarOriginLocationMethods for DissimilarOriginLocation {
diff --git a/components/script/dom/dissimilaroriginwindow.rs b/components/script/dom/dissimilaroriginwindow.rs
index 0f3cbd06df0..e4e8b0dad40 100644
--- a/components/script/dom/dissimilaroriginwindow.rs
+++ b/components/script/dom/dissimilaroriginwindow.rs
@@ -19,6 +19,7 @@ use js::jsval::{JSVal, UndefinedValue};
use msg::constellation_msg::PipelineId;
use script_traits::ScriptMsg as ConstellationMsg;
use servo_url::ImmutableOrigin;
+use servo_url::MutableOrigin;
use servo_url::ServoUrl;
/// Represents a dissimilar-origin `Window` that exists in another script thread.
@@ -56,12 +57,17 @@ impl DissimilarOriginWindow {
global_to_clone_from.constellation_chan().clone(),
global_to_clone_from.scheduler_chan().clone(),
global_to_clone_from.resource_threads().clone(),
- timer_event_chan),
+ timer_event_chan,
+ global_to_clone_from.origin().clone()),
browsing_context: JS::from_ref(browsing_context),
location: MutNullableJS::new(None),
};
unsafe { DissimilarOriginWindowBinding::Wrap(cx, win) }
}
+
+ pub fn origin(&self) -> &MutableOrigin {
+ self.globalscope.origin()
+ }
}
impl DissimilarOriginWindowMethods for DissimilarOriginWindow {
diff --git a/components/script/dom/globalscope.rs b/components/script/dom/globalscope.rs
index 73ba61e4557..931d1f576aa 100644
--- a/components/script/dom/globalscope.rs
+++ b/components/script/dom/globalscope.rs
@@ -38,7 +38,7 @@ use script_runtime::{CommonScriptMsg, ScriptChan, ScriptPort};
use script_thread::{MainThreadScriptChan, RunnableWrapper, ScriptThread};
use script_traits::{MsDuration, ScriptMsg as ConstellationMsg, TimerEvent};
use script_traits::{TimerEventId, TimerSchedulerMsg, TimerSource};
-use servo_url::ServoUrl;
+use servo_url::{MutableOrigin, ServoUrl};
use std::cell::Cell;
use std::collections::HashMap;
use std::collections::hash_map::Entry;
@@ -92,6 +92,9 @@ pub struct GlobalScope {
resource_threads: ResourceThreads,
timers: OneshotTimers,
+
+ /// The origin of the globalscope
+ origin: MutableOrigin,
}
impl GlobalScope {
@@ -103,7 +106,8 @@ impl GlobalScope {
constellation_chan: IpcSender<ConstellationMsg>,
scheduler_chan: IpcSender<TimerSchedulerMsg>,
resource_threads: ResourceThreads,
- timer_event_chan: IpcSender<TimerEvent>)
+ timer_event_chan: IpcSender<TimerEvent>,
+ origin: MutableOrigin)
-> Self {
GlobalScope {
eventtarget: EventTarget::new_inherited(),
@@ -120,6 +124,7 @@ impl GlobalScope {
in_error_reporting_mode: Default::default(),
resource_threads: resource_threads,
timers: OneshotTimers::new(timer_event_chan, scheduler_chan),
+ origin: origin,
}
}
@@ -238,6 +243,11 @@ impl GlobalScope {
self.pipeline_id
}
+ /// Get the origin for this global scope
+ pub fn origin(&self) -> &MutableOrigin {
+ &self.origin
+ }
+
/// Get the [base url](https://html.spec.whatwg.org/multipage/#api-base-url)
/// for this global scope.
pub fn api_base_url(&self) -> ServoUrl {
diff --git a/components/script/dom/location.rs b/components/script/dom/location.rs
index 399e3748722..854cdf424c2 100644
--- a/components/script/dom/location.rs
+++ b/components/script/dom/location.rs
@@ -13,7 +13,7 @@ use dom::globalscope::GlobalScope;
use dom::urlhelper::UrlHelper;
use dom::window::Window;
use dom_struct::dom_struct;
-use servo_url::ServoUrl;
+use servo_url::{MutableOrigin, ServoUrl};
#[dom_struct]
pub struct Location {
@@ -60,6 +60,10 @@ impl Location {
pub fn reload_without_origin_check(&self) {
self.window.load_url(self.get_url(), true, true, None);
}
+
+ pub fn origin(&self) -> &MutableOrigin {
+ self.window.origin()
+ }
}
impl LocationMethods for Location {
diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs
index df7fe995c1f..eaba1ded928 100644
--- a/components/script/dom/window.rs
+++ b/components/script/dom/window.rs
@@ -85,7 +85,7 @@ use servo_atoms::Atom;
use servo_config::opts;
use servo_config::prefs::PREFS;
use servo_geometry::{f32_rect_to_au_rect, max_rect};
-use servo_url::{Host, ImmutableOrigin, ServoUrl};
+use servo_url::{Host, MutableOrigin, ImmutableOrigin, ServoUrl};
use std::ascii::AsciiExt;
use std::borrow::ToOwned;
use std::cell::Cell;
@@ -286,6 +286,10 @@ impl Window {
}
}
+ pub fn origin(&self) -> &MutableOrigin {
+ self.globalscope.origin()
+ }
+
pub fn get_cx(&self) -> *mut JSContext {
self.js_runtime.borrow().as_ref().unwrap().cx()
}
@@ -1749,6 +1753,7 @@ impl Window {
id: PipelineId,
parent_info: Option<(PipelineId, FrameType)>,
window_size: Option<WindowSizeData>,
+ origin: MutableOrigin,
webvr_thread: Option<IpcSender<WebVRMsg>>)
-> Root<Window> {
let layout_rpc: Box<LayoutRPC + Send> = {
@@ -1771,7 +1776,8 @@ impl Window {
constellation_chan,
scheduler_chan,
resource_threads,
- timer_event_chan),
+ timer_event_chan,
+ origin),
script_chan: script_chan,
dom_manipulation_task_source: dom_task_source,
user_interaction_task_source: user_task_source,
diff --git a/components/script/dom/workerglobalscope.rs b/components/script/dom/workerglobalscope.rs
index 948d72c251b..fd1f03db1e3 100644
--- a/components/script/dom/workerglobalscope.rs
+++ b/components/script/dom/workerglobalscope.rs
@@ -37,7 +37,7 @@ use script_runtime::{CommonScriptMsg, ScriptChan, ScriptPort};
use script_thread::RunnableWrapper;
use script_traits::{TimerEvent, TimerEventId};
use script_traits::WorkerGlobalScopeInit;
-use servo_url::ServoUrl;
+use servo_url::{MutableOrigin, ServoUrl};
use std::default::Default;
use std::rc::Rc;
use std::sync::Arc;
@@ -59,6 +59,7 @@ pub fn prepare_workerscope_init(global: &GlobalScope,
scheduler_chan: global.scheduler_chan().clone(),
worker_id: global.get_next_worker_id(),
pipeline_id: global.pipeline_id(),
+ origin: global.origin().immutable().clone(),
};
init
@@ -109,7 +110,8 @@ impl WorkerGlobalScope {
init.constellation_chan,
init.scheduler_chan,
init.resource_threads,
- timer_event_chan),
+ timer_event_chan,
+ MutableOrigin::new(init.origin)),
worker_id: init.worker_id,
worker_url: worker_url,
closing: closing,
diff --git a/components/script/script_thread.rs b/components/script/script_thread.rs
index 92537fa7abe..96167cec236 100644
--- a/components/script/script_thread.rs
+++ b/components/script/script_thread.rs
@@ -1784,6 +1784,7 @@ impl ScriptThread {
incomplete.pipeline_id,
incomplete.parent_info,
incomplete.window_size,
+ incomplete.origin.clone(),
self.webvr_thread.clone());
// Initialize the browsing context for the window.
diff --git a/components/script_traits/lib.rs b/components/script_traits/lib.rs
index da5191f73bd..ed0e09468ac 100644
--- a/components/script_traits/lib.rs
+++ b/components/script_traits/lib.rs
@@ -777,6 +777,8 @@ pub struct WorkerGlobalScopeInit {
pub worker_id: WorkerId,
/// The pipeline id
pub pipeline_id: PipelineId,
+ /// The origin
+ pub origin: ImmutableOrigin,
}
/// Common entities representing a network load origin