author | Terrence Cole <terrence@trainedmonkeystudios.org> |
Mon, 26 Sep 2011 15:17:05 -0700 | |
changeset 78947 | c4b5ba89b4b7ae9a7d765ebbdd24b5b9ed15a1a2 |
parent 78946 | ed95d68c0f85cceac8c667277e7578792f80aeb0 |
child 78948 | ebb656c6410ea49cb5f19e1071f2915e0b569976 |
push id | 78 |
push user | clegnitto@mozilla.com |
push date | Fri, 16 Dec 2011 17:32:24 +0000 |
treeherder | mozilla-release@79d24e644fdd [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | jwalden |
bugs | 688646 |
milestone | 9.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
js/src/shell/js.cpp | file | annotate | diff | comparison | revisions | |
js/src/tests/ecma_3/Function/15.3.4.4-1.js | file | annotate | diff | comparison | revisions | |
js/src/tests/js1_5/Function/15.3.4.4.js | file | annotate | diff | comparison | revisions | |
js/src/tests/js1_5/Function/jstests.list | file | annotate | diff | comparison | revisions |
--- a/js/src/shell/js.cpp +++ b/js/src/shell/js.cpp @@ -4630,68 +4630,16 @@ static JSPropertySpec its_props[] = { {"rdonly", ITS_RDONLY, JSPROP_READONLY, NULL, NULL}, {"custom", ITS_CUSTOM, JSPROP_ENUMERATE, its_getter, its_setter}, {"customRdOnly", ITS_CUSTOMRDONLY, JSPROP_ENUMERATE | JSPROP_READONLY, its_getter, its_setter}, {NULL,0,0,NULL,NULL} }; -static JSBool -its_bindMethod(JSContext *cx, uintN argc, jsval *vp) -{ - JSString *name; - JSObject *method; - - JSObject *thisobj = JS_THIS_OBJECT(cx, vp); - - if (!JS_ConvertArguments(cx, argc, JS_ARGV(cx, vp), "So", &name, &method)) - return JS_FALSE; - - *vp = OBJECT_TO_JSVAL(method); - - if (JS_TypeOfValue(cx, *vp) != JSTYPE_FUNCTION) { - JSAutoByteString nameBytes(cx, name); - if (!!nameBytes) { - JSString *valstr = JS_ValueToString(cx, *vp); - if (valstr) { - JSAutoByteString valBytes(cx, valstr); - if (!!valBytes) { - JS_ReportError(cx, "can't bind method %s to non-callable object %s", - nameBytes.ptr(), valBytes.ptr()); - } - } - } - return JS_FALSE; - } - - if (method->getFunctionPrivate()->isInterpreted() && - method->getFunctionPrivate()->script()->compileAndGo) { - /* Can't reparent compileAndGo scripts. */ - JSAutoByteString nameBytes(cx, name); - if (!!nameBytes) - JS_ReportError(cx, "can't bind method %s to compileAndGo script", nameBytes.ptr()); - return JS_FALSE; - } - - jsid id; - if (!JS_ValueToId(cx, STRING_TO_JSVAL(name), &id)) - return JS_FALSE; - - if (!JS_DefinePropertyById(cx, thisobj, id, *vp, NULL, NULL, JSPROP_ENUMERATE)) - return JS_FALSE; - - return JS_SetParent(cx, method, thisobj); -} - -static JSFunctionSpec its_methods[] = { - {"bindMethod", its_bindMethod, 2,0}, - {NULL,NULL,0,0} -}; - #ifdef JSD_LOWLEVEL_SOURCE /* * This facilitates sending source to JSD (the debugger system) in the shell * where the source is loaded using the JSFILE hack in jsscan. The function * below is used as a callback for the jsdbgapi JS_SetSourceHandler hook. * A more normal embedding (e.g. mozilla) loads source itself and can send * source directly to JSD without using this hook scheme. */ @@ -5334,18 +5282,16 @@ NewGlobalObject(JSContext *cx, Compartme return NULL; } JSObject *it = JS_DefineObject(cx, glob, "it", &its_class, NULL, 0); if (!it) return NULL; if (!JS_DefineProperties(cx, it, its_props)) return NULL; - if (!JS_DefineFunctions(cx, it, its_methods)) - return NULL; if (!JS_DefineProperty(cx, glob, "custom", JSVAL_VOID, its_getter, its_setter, 0)) return NULL; if (!JS_DefineProperty(cx, glob, "customRdOnly", JSVAL_VOID, its_getter, its_setter, JSPROP_READONLY)) return NULL; }
--- a/js/src/tests/ecma_3/Function/15.3.4.4-1.js +++ b/js/src/tests/ecma_3/Function/15.3.4.4-1.js @@ -147,16 +147,25 @@ addThis(); * Function.prototype.call() and * Function.prototype.call(null) should return the same result */ status = inSection(10); actual = F2.call(null); expect = F2.call(); addThis(); +/* + * Function.prototype.call gets lexical globals, not caller globals + */ +status = inSection(11); +actual = g2 = newGlobal('new-compartment'); +g2.eval("boundMethod = Function('return this');"); +expect = g2.boundMethod.call(); +addThis(); + //----------------------------------------------------------------------------- test(); //-----------------------------------------------------------------------------
deleted file mode 100644 --- a/js/src/tests/js1_5/Function/15.3.4.4.js +++ /dev/null @@ -1,73 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is JavaScript Engine testing utilities. - * - * The Initial Developer of the Original Code is - * Mozilla Foundation. - * Portions created by the Initial Developer are Copyright (C) 2005 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): Brendan Eich - * - * Alternatively, the contents of this file may be used under the terms of - * either the GNU General Public License Version 2 or later (the "GPL"), or - * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -//----------------------------------------------------------------------------- -var BUGNUMBER = 290488; -var summary = '15.3.4.4 - Function.prototype.call() Scope'; -var actual = ''; -var expect = ''; -var description = ''; -var GLOBAL = this; - -printBugNumber(BUGNUMBER); -printStatus (summary); - -printStatus(inSection(1)); - -function func() { return this; } - -description = 'top-level function: this == GLOBAL'; -expect = GLOBAL; -actual = func.call(); -reportCompare(expect, actual, description); - -printStatus(inSection(2)); - -function getBoundMethod() -{ - return it.bindMethod("boundMethod", Function("return this")); -} - -// it is a js shell only construction -if (typeof it != 'undefined') -{ - description = 'bound method: this == GLOBAL'; - var func = getBoundMethod(); - expect = GLOBAL; - actual = func.call(); - reportCompare(expect, actual, description); -}
--- a/js/src/tests/js1_5/Function/jstests.list +++ b/js/src/tests/js1_5/Function/jstests.list @@ -1,12 +1,11 @@ url-prefix ../../jsreftest.html?test=js1_5/Function/ script 10.1.6-01.js script 10.1.6.js -script 15.3.4.4.js script regress-123371.js script regress-178389.js script regress-222029-001.js script regress-222029-002.js script regress-292215.js #skip-if(Android) silentfail script regress-338001.js # disabled pending bug 657444 #skip-if(Android) silentfail script regress-338121-01.js # disabled pending bug 657444 #skip-if(Android) silentfail script regress-338121-02.js # disabled pending bug 657444