aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors-servo <release+servo@mozilla.com>2013-11-17 19:19:24 -0800
committerbors-servo <release+servo@mozilla.com>2013-11-17 19:19:24 -0800
commit426d18ffb102533d6acf7162f772f58d5cf29b23 (patch)
tree4076469b2ab0ddf3d62e0855429e5dac4fea1287
parentc5ecc0da39b0e16d271ee8ed028231425406a3be (diff)
parent853bcba0d1758ee92fb3bf4975e582c910d28a16 (diff)
downloadservo-426d18ffb102533d6acf7162f772f58d5cf29b23.tar.gz
servo-426d18ffb102533d6acf7162f772f58d5cf29b23.zip
auto merge of #1219 : ksh8281/servo/impl_window_self, r=jdm
in order to Implement window.self #868
-rw-r--r--src/components/script/dom/window.rs17
-rw-r--r--src/test/html/content/test_window.html13
2 files changed, 24 insertions, 6 deletions
diff --git a/src/components/script/dom/window.rs b/src/components/script/dom/window.rs
index 64edfdf4baf..7303d5d81f0 100644
--- a/src/components/script/dom/window.rs
+++ b/src/components/script/dom/window.rs
@@ -223,13 +223,18 @@ impl Window {
let global = WindowBinding::Wrap(cx, ptr::null(), win);
unsafe {
- do "window".to_c_str().with_ref |name| {
- JS_DefineProperty(cx, global, name,
- RUST_OBJECT_TO_JSVAL(global),
- Some(GetJSClassHookStubPointer(PROPERTY_STUB) as JSPropertyOp),
- Some(GetJSClassHookStubPointer(STRICT_PROPERTY_STUB) as JSStrictPropertyOp),
- JSPROP_ENUMERATE);
+ let fn_names = ["window","self"];
+ for str in fn_names.iter() {
+ do (*str).to_c_str().with_ref |name| {
+ JS_DefineProperty(cx, global, name,
+ RUST_OBJECT_TO_JSVAL(global),
+ Some(GetJSClassHookStubPointer(PROPERTY_STUB) as JSPropertyOp),
+ Some(GetJSClassHookStubPointer(STRICT_PROPERTY_STUB) as JSStrictPropertyOp),
+ JSPROP_ENUMERATE);
+ }
+
}
+
}
win
}
diff --git a/src/test/html/content/test_window.html b/src/test/html/content/test_window.html
new file mode 100644
index 00000000000..f532929a124
--- /dev/null
+++ b/src/test/html/content/test_window.html
@@ -0,0 +1,13 @@
+<html>
+<head>
+ <title></title>
+ <script src="harness.js"></script>
+</head>
+<body>
+<script>
+is(window, window.self);
+is_a(window.self, Window);
+finish();
+</script>
+</body>
+</html>