Bug 157782 - console namespace breaks putting properties on console.__proto__
Summary: console namespace breaks putting properties on console.__proto__
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: JavaScriptCore (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Joseph Pecoraro
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2016-05-16 20:10 PDT by Joseph Pecoraro
Modified: 2016-05-17 11:20 PDT (History)
11 users (show)

See Also:


Attachments
[PATCH] Proposed Fix - DeprecatedConsolePrototype emits warnings (25.20 KB, patch)
2016-05-16 20:29 PDT, Joseph Pecoraro
no flags Details | Formatted Diff | Diff
[PATCH] Proposed Fix - Simple Approach (2.06 KB, patch)
2016-05-16 20:34 PDT, Joseph Pecoraro
no flags Details | Formatted Diff | Diff
[PATCH] Proposed Fix - DeprecatedConsolePrototype emits warnings (25.71 KB, patch)
2016-05-16 20:38 PDT, Joseph Pecoraro
no flags Details | Formatted Diff | Diff
[PATCH] Proposed Fix - Simple Approach (4.50 KB, patch)
2016-05-16 20:44 PDT, Joseph Pecoraro
ggaren: review+
buildbot: commit-queue-
Details | Formatted Diff | Diff
Archive of layout-test-results from ews107 for mac-yosemite-wk2 (1.29 MB, application/zip)
2016-05-16 21:11 PDT, Build Bot
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph Pecoraro 2016-05-16 20:10:38 PDT
* SUMMARY
console namespace breaks putting properties on console.__proto__

Regression with r200350. Console moved to a vanilla namespace object. So console.__proto__ used to be be ConsolePrototype (with log, warn, ... functions) but is now Object.prototype as those functions are on the console object itself.

* STEPS TO REPRODUCE
1. Open http://www.macupdate.com/app/mac/25347/phoneview
2. Attempt to click the "More..." link
  => Does not work. Issues in console on page load.

* NOTES
- Page adds property to console.__proto__ which is now Object.prototype.
http://www.macupdate.com/js/_sources/compressed/mu.utils.min.js (pretty printed)
111:    }, console.__proto__.debug = function(format) {
112:        if (window.DEBUG) {
113:            var varargs = Array.prototype.slice.call(arguments);
114:            console.__proto__.info.apply(this, varargs)
115:        }
116:    }

- Causes issues later on iterating a vanilla object, which was unexpected.
for (var p in {}) console.log(p); // "debug"
Comment 1 Joseph Pecoraro 2016-05-16 20:11:00 PDT
<rdar://problem/26250526>
Comment 2 Joseph Pecoraro 2016-05-16 20:29:38 PDT
Created attachment 279088 [details]
[PATCH] Proposed Fix - DeprecatedConsolePrototype emits warnings
Comment 3 WebKit Commit Bot 2016-05-16 20:31:56 PDT
Attachment 279088 [details] did not pass style-queue:


ERROR: Source/JavaScriptCore/inspector/JSGlobalObjectConsoleClient.h:45:  The parameter name "message" adds no information, so it should be removed.  [readability/parameter_name] [5]
Total errors found: 1 in 17 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 4 Joseph Pecoraro 2016-05-16 20:34:24 PDT
Created attachment 279089 [details]
[PATCH] Proposed Fix - Simple Approach
Comment 5 Joseph Pecoraro 2016-05-16 20:35:51 PDT
Here are two approaches (I forgot CMakeLists.txt in the first patch).

1. DeprecatedConsolePrototype
- Make console.__proto__ a new vanilla object.
- emits a console warning when pages put properties on console.__proto__ to move developers away from using it.

2. Simple Approach
- Make console.__proto__ a new vanilla object.
Comment 6 Joseph Pecoraro 2016-05-16 20:38:53 PDT
Created attachment 279091 [details]
[PATCH] Proposed Fix - DeprecatedConsolePrototype emits warnings
Comment 7 WebKit Commit Bot 2016-05-16 20:41:17 PDT
Attachment 279091 [details] did not pass style-queue:


ERROR: Source/JavaScriptCore/inspector/JSGlobalObjectConsoleClient.h:45:  The parameter name "message" adds no information, so it should be removed.  [readability/parameter_name] [5]
Total errors found: 1 in 18 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 8 Joseph Pecoraro 2016-05-16 20:44:57 PDT
Created attachment 279093 [details]
[PATCH] Proposed Fix - Simple Approach
Comment 9 Build Bot 2016-05-16 21:11:31 PDT
Comment on attachment 279093 [details]
[PATCH] Proposed Fix - Simple Approach

Attachment 279093 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.webkit.org/results/1334378

Number of test failures exceeded the failure limit.
Comment 10 Build Bot 2016-05-16 21:11:34 PDT
Created attachment 279098 [details]
Archive of layout-test-results from ews107 for mac-yosemite-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews107  Port: mac-yosemite-wk2  Platform: Mac OS X 10.10.5
Comment 11 Geoffrey Garen 2016-05-17 10:48:42 PDT
Comment on attachment 279093 [details]
[PATCH] Proposed Fix - Simple Approach

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

> Source/JavaScriptCore/runtime/JSGlobalObject.cpp:201
> +    // FIXME: <https://webkit.org/b/157782> console namespace breaks putting properties on console.__proto__
> +    // Give console namespace a basic prototype object to avoid backwards compatibility issues from when
> +    // there used to be a console.__proto__ before it became a namespace object.

I don't think we want a FIXME here. A FIXME should indicate a definite change we expect to make in the future. But we don't have any plan to change here.

I would remove this comment.
Comment 12 Geoffrey Garen 2016-05-17 10:49:16 PDT
Comment on attachment 279093 [details]
[PATCH] Proposed Fix - Simple Approach

r=me

EWS failure seems spurious.
Comment 13 Joseph Pecoraro 2016-05-17 11:20:02 PDT
Landed Simple Approach:
<http://trac.webkit.org/changeset/201022>