Reviewers: Feng Qian,

http://codereview.chromium.org/99352/diff/1/2
File src/ia32/codegen-ia32.cc (right):

http://codereview.chromium.org/99352/diff/1/2#newcode653
Line 653: //
http://www.mozilla.org/js/language/js20-2002-04/core/operators.html#operator-overriding
it can be done in Runtime_Typeof. Will add it.
On 2009/05/04 17:31:58, Feng Qian wrote:
> How about (typeof Document.load == 'function')? __toBoolean__ may not
be exact
> the same as undetectable document.all. You can 'grep Undetectable
ia32/*' to
> find other cases handling document.all. Some of operations are
inlined.

http://codereview.chromium.org/99352/diff/1/4
File src/runtime.cc (right):

http://codereview.chromium.org/99352/diff/1/4#newcode2993
Line 2993: if (rv && rv->IsJSFunction())
I used to return NULL in Runtime::GetToBooleanOperator. Now checking rv
is unnecessary, will remove it.
On 2009/05/04 17:31:58, Feng Qian wrote:
> rv cannot be null, rv->IsJSFunction() is good enough.

> Heap::null_value() is a value, you can check it by rv->IsNull(), but
it is
> unnecessary if checking IsJSFunction() here.

Description:
Some pages have site compatibility issues because they call some
non-standard methods, such as "load()" method of document object. IE and
Firefox support it but Chrome does not.
For catching this kinds of issues, we can add a fake function which is
bound to the missed method. When the code of original page calls the
fake function, we catch this problem.
But if page script tries to check whether the browser supports this
non-standard method or not before calling it, such as the following code
if (document.load)
   documeent.load("", url, null);
else
   ...
which means the web developer is aware that using this method might
cause potential compatibility issues. In this case we shouldn't let the
script considers that current browser supports this method and call it
because the method is fake(added by us). But since we do add the method,
we need to make the new added fake method undetectable (like
"document.all").
To aim this, I introduce and implemente the __toBoolean__ operator into
my V8 build. The idea is from Mozilla JS2.0 draft, operator overriding.
(http://www.mozilla.org/js/language/js20-2002-04/core/operators.html#operator-overriding.)
Just like toString, every object(include function) might have a
__toBoolean__ method that can be overridden. This method is called by
statements such as if, while, do while, and for and operators such as !,
||, ^^, &&, and ? :.


Please review this at http://codereview.chromium.org/99352

SVN Base: http://v8.googlecode.com/svn/trunk/

Affected files:
   M     src/builtins.h
   M     src/ia32/codegen-ia32.cc
   M     src/runtime.h
   M     src/runtime.cc
   M     src/runtime.js



--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to