Page MenuHomePhabricator

ResourceLoader: remove check for `console.warn` support
Closed, ResolvedPublic

Description

startup/mediawiki.js currently checks if console.warn is truthy, and if so binds mw.log.warn to it, and if not make mw.log.warn a no-op:
https://gerrit.wikimedia.org/r/plugins/gitiles/mediawiki/core/+/1683136df1e6b20e5c12453671dad98b9425fc22/resources/src/startup/mediawiki.js#169

/**
 * Write a message to the browser console's warning channel.
 *
 * This method is a no-op in browsers that don't implement the Console API.
 *
 * @param {...string} msg Messages to output to console
 */
log.warn = con.warn ?
	Function.prototype.bind.call( con.warn, con ) :
	function () {};

based on the browser support at https://www.mediawiki.org/wiki/Compatibility#Browser_support_matrix and caniuse for console operations (https://caniuse.com/mdn-api_console_warn) it appears that all supported browsers implement the console API, and specifically the warn method. Can the check be removed?

Event Timeline

Restricted Application added a subscriber: Aklapper. · View Herald Transcript

Happy to tackle this myself just wanted to make sure I wasn't missing anything with removing the check, if its okay with the performance team I'll send a patch.

Sounds good to me. Can do the same with console.error in mediawiki.base/log.js.

DannyS712 moved this task from Unsorted to Next on the User-DannyS712 board.

Change 865524 had a related patch set uploaded (by DannyS712; author: DannyS712):

[mediawiki/core@master] resourceloader: assume Console API is always available

https://gerrit.wikimedia.org/r/865524

Sounds good to me. Can do the same with console.error in mediawiki.base/log.js.

Also found a few others like console.log, included in the same patch

Krinkle triaged this task as Medium priority.

Thanks!

Change 865524 merged by jenkins-bot:

[mediawiki/core@master] resourceloader: assume Console API is always available

https://gerrit.wikimedia.org/r/865524