From 515c38731e81587c9024288ba182039abd7b2184 Mon Sep 17 00:00:00 2001 From: Domenic Denicola Date: Fri, 18 Mar 2016 16:09:05 -0400 Subject: [PATCH] Remove various realm equality checks Instead, just use the realm of the `this` value consistently. --- spec.html | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/spec.html b/spec.html index 17045e7..d4ae138 100644 --- a/spec.html +++ b/spec.html @@ -39,10 +39,7 @@

Zone ( _options_ )

1. If NewTarget is *undefined*, throw a *TypeError* exception. - 1. Let _newTargetRealm_ be ? GetFunctionRealm(NewTarget). 1. Let _functionRealm_ be ? GetFunctionRealm(the active function object). - 1. Let _currentRealm_ be the current Realm Record. - 1. If _newTargetRealm_, _functionRealm_, and _currentRealm_ are not all equal, throw a *TypeError* exception. 1. Let _name_ be `"(unnamed zone)"`. 1. Let _parent_ be *null*. 1. If _options_ is *undefined*, set _options_ to ! ObjectCreate(%ObjectPrototype%). @@ -93,28 +90,8 @@

get Zone.current

1. Let _C_ be the *this* value. 1. If IsCallable(_C_) is *false*, throw a *TypeError* exception. 1. Let _thisRealm_ be ? GetFunctionRealm(_C_). - 1. Let _f_ be the active function object. - 1. Let _functionRealm_ be ? GetFunctionRealm(_f_). - 1. Let _currentRealm_ be the current Realm Record. - 1. If _thisRealm_, _functionRealm_, and _currentRealm_ are not all equal, throw a *TypeError* exception. 1. Return _thisRealm_.[[CurrentZone]].
- - -

This getter is intentionally restricted to prevent running the current zone of another realm. Assume the following code runs in a realm realm1 whose global object is `global1`, but has access to the global objects of two other realms, realm2 and realm3, via `global2` and `global3`. Then:

- -
global1.Zone.current; // succeeds: currentRealm = thisRealm = functionRealm = realm1
-global2.Zone.current; // throws: currentRealm = realm1; thisRealm = functionRealm = realm2
-
-const getter1 = Object.getOwnPropertyDescriptor(global1.Zone, "current").get;
-const getter2 = Object.getOwnPropertyDescriptor(global2.Zone, "current").get;
-const getter3 = Object.getOwnPropertyDescriptor(global3.Zone, "current").get;
-
-getter1.call(global2.Zone); // throws: currentRealm = functionRealm = realm1; thisRealm = realm2
-getter2.call(global1.Zone); // throws: currentRealm = thisRealm = realm1; functionRealm = realm2
-getter2.call(global3.Zone); // throws: currentRealm = realm1; functionRealm = realm2; thisRealm = realm3
-
-
@@ -176,10 +153,6 @@

Zone.prototype.run ( _callback_ )

1. If _Z_ does not have a [[ParentZone]] internal slot, throw a *TypeError* exception. 1. If IsCallable(_callback_) is *false*, throw a *TypeError* exception. 1. Let _thisRealm_ be the value of _Z_'s [[Realm]] internal slot. - 1. Let _functionRealm_ be ? GetFunctionRealm(the active function object). - 1. Let _callbackRealm_ be ? GetFunctionRealm(_callback_). - 1. Let _currentRealm_ be the current Realm Record. - 1. If _thisRealm_, _functionRealm_, _callbackRealm_, and _currentRealm_ are not all equal, throw a *TypeError* exception. 1. Let _beforeZone_ be _thisRealm_.[[CurrentZone]]. 1. Set _thisRealm_.[[CurrentZone]] to _Z_. 1. Let _status_ be Call(_callback_, *undefined*, « »).