Bug 139129 - document.all can be both 'function' and 'not function'
Summary: document.all can be both 'function' and 'not function'
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-12-01 07:39 PST by Rajaram Gaunker
Modified: 2016-09-17 07:02 PDT (History)
4 users (show)

See Also:


Attachments
Patch (1.57 KB, patch)
2014-12-01 07:55 PST, Rajaram Gaunker
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from webkit-ews-12 for mac-mountainlion-wk2 (505.22 KB, application/zip)
2014-12-01 09:01 PST, Build Bot
no flags Details
Archive of layout-test-results from webkit-ews-06 for mac-mountainlion (516.91 KB, application/zip)
2014-12-01 09:24 PST, Build Bot
no flags Details
Patch (8.64 KB, patch)
2014-12-02 04:39 PST, Rajaram Gaunker
no flags Details | Formatted Diff | Diff
Patch (8.64 KB, patch)
2014-12-02 09:42 PST, Rajaram Gaunker
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Rajaram Gaunker 2014-12-01 07:39:33 PST
typeof document.all === 'function' return true 
and 
var type = typeof document.all;
type === 'function' will return false.

So if you combine two statements or keep them separate they return different answer.

This is happening because document.all is returned to be CallTypeHost.

From spec https://html.spec.whatwg.org/#dom-document-all
"The user agent must act such that the typeof operator in JavaScript returns the string undefined when applied to the object returned for all."
Comment 1 Rajaram Gaunker 2014-12-01 07:55:00 PST
Created attachment 242310 [details]
Patch
Comment 2 WebKit Commit Bot 2014-12-01 07:59:03 PST
Comment on attachment 242310 [details]
Patch

Rejecting attachment 242310 [details] from commit-queue.

zimbabao@gmail.com does not have committer permissions according to http://trac.webkit.org/browser/trunk/Tools/Scripts/webkitpy/common/config/contributors.json.

- If you do not have committer rights please read http://webkit.org/coding/contributing.html for instructions on how to use bugzilla flags.

- If you have committer rights please correct the error in Tools/Scripts/webkitpy/common/config/contributors.json by adding yourself to the file (no review needed).  The commit-queue restarts itself every 2 hours.  After restart the commit-queue will correctly respect your committer rights.
Comment 3 Build Bot 2014-12-01 09:00:57 PST
Comment on attachment 242310 [details]
Patch

Attachment 242310 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.appspot.com/results/6331413246771200

New failing tests:
fast/dom/collection-null-like-arguments.html
fast/dom/htmlallcollection-call-with-index-caching-bug.html
Comment 4 Build Bot 2014-12-01 09:01:00 PST
Created attachment 242314 [details]
Archive of layout-test-results from webkit-ews-12 for mac-mountainlion-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: webkit-ews-12  Port: mac-mountainlion-wk2  Platform: Mac OS X 10.8.5
Comment 5 Build Bot 2014-12-01 09:24:41 PST
Comment on attachment 242310 [details]
Patch

Attachment 242310 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.appspot.com/results/5108600087248896

New failing tests:
fast/dom/collection-null-like-arguments.html
fast/dom/htmlallcollection-call-with-index-caching-bug.html
Comment 6 Build Bot 2014-12-01 09:24:44 PST
Created attachment 242315 [details]
Archive of layout-test-results from webkit-ews-06 for mac-mountainlion

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: webkit-ews-06  Port: mac-mountainlion  Platform: Mac OS X 10.8.5
Comment 7 Sam Weinig 2014-12-01 16:29:13 PST
Comment on attachment 242310 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=242310&action=review

> Source/WebCore/ChangeLog:8
> +        No new tests

This definitely needs tests.
Comment 8 Rajaram Gaunker 2014-12-02 04:39:25 PST
Created attachment 242399 [details]
Patch
Comment 9 Darin Adler 2014-12-02 09:09:04 PST
Comment on attachment 242399 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=242399&action=review

> Source/JavaScriptCore/runtime/CallData.h:45
> +    CallTypeCallbleNonFunctionHost,

"Callble" is not a word
Comment 10 Rajaram Gaunker 2014-12-02 09:42:19 PST
Created attachment 242419 [details]
Patch
Comment 11 Geoffrey Garen 2014-12-02 13:16:08 PST
Comment on attachment 242419 [details]
Patch

It's almost certainly wrong to do this just for document.all. What about all the other callable APIs in the DOM?

Also, why do we think that undefined is the right value for typeof? What's the source on that?
Comment 12 Rajaram Gaunker 2014-12-02 17:41:00 PST
@ggaren:
Doing it for document.write because that what is mentioned in spec
https://html.spec.whatwg.org/#dom-document-all
"The user agent must act such that the typeof operator in JavaScript returns the string undefined when applied to the object returned for all."

Are there more such APIs?.

Also at present 
(type=typeof document.all, type === 'function')", "(typeof document.all === 'function') 

return false. Equivalent code pieces giving out different results, which is wrong.

and 

currently typeof document.all returnrs 'undefined'.
Comment 13 Michael Catanzaro 2016-09-17 07:02:15 PDT
Comment on attachment 242419 [details]
Patch

Hi,

Apologies that your patch was not reviewed in a timely manner. Since it's now quite old, I am removing it from the review request queue. Please consider rebasing it on trunk and resubmitting.

To increase the chances of getting a review, consider using 'Tools/Scripts/webkit-patch upload --suggest-reviewers' to CC reviewers who might be interested in this bug.