mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-03 12:35:58 +00:00
As the scope parameter for the bind and getBase methods should never be null, make sure they trigger NullPointerException on "scope == null" to detect bad API usage earlier.
This commit is contained in:
parent
e5b390ed80
commit
050ea5f4cf
@ -1092,19 +1092,19 @@ public class ScriptRuntime {
|
||||
* See ECMA 10.1.4
|
||||
*/
|
||||
public static Scriptable bind(Scriptable scope, String id) {
|
||||
Scriptable obj = scope;
|
||||
while (obj != null && !ScriptableObject.hasProperty(obj, id)) {
|
||||
obj = obj.getParentScope();
|
||||
while (!ScriptableObject.hasProperty(scope, id)) {
|
||||
scope = scope.getParentScope();
|
||||
if (scope == null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
return scope;
|
||||
}
|
||||
|
||||
public static Scriptable getBase(Scriptable scope, String id) {
|
||||
Scriptable obj = scope;
|
||||
while (obj != null) {
|
||||
if (ScriptableObject.hasProperty(obj, id))
|
||||
return obj;
|
||||
obj = obj.getParentScope();
|
||||
Scriptable base = bind(scope, id);
|
||||
if (base != null) {
|
||||
return base;
|
||||
}
|
||||
throw NativeGlobal.constructError(
|
||||
Context.getContext(), "ReferenceError",
|
||||
|
Loading…
x
Reference in New Issue
Block a user