Page MenuHomePhabricator

Rename $.client.test() to $.client.isRejected()
Closed, DeclinedPublicFeature

Description

Sometimes it does make sense to use user-agent sniffing for blacklisting known-buggy browsers; at some point jquery.client.js got switched in to allow unrecognized browsers to pass through as assumed-good (which is good!)

However the version maps you pass to $.client.test() are in a whitelist format (eg, msie: [[">=", 7]] for "works on 7 or later") and it's hard to tell from calling code that it's actually a blacklist.

May encourage better coding practice to swap the order and use blacklist explicitly in the name, so eg WikiEditor's map might change to:

'browsers': {

		// Left-to-right languages
		'ltr': {
			// The toolbar layout is broken in IE6
			'msie': [['<', 7]],
			// Layout issues in FF < 2
			'firefox': [['<', 2]],
			// Text selection bugs galore - this may be a different situation with the new iframe-based solution
			'opera': [['<', 9.6]],
			// jQuery minimums
			'safari': [['<', 3]],
			'chrome': [['<', 3]],
			'netscape': [['<', 9]],
			'blackberry': false,
			'ipod': false,
			'iphone': false
		},
		// Right-to-left languages
		'rtl': {
			// The toolbar layout is broken in IE 7 in RTL mode, and IE6 in any mode
			'msie': [['<', 8]],
			// Layout issues in FF < 2
			'firefox': [['<', 2]],
			// Text selection bugs galore - this may be a different situation with the new iframe-based solution
			'opera': [['<', 9.6]],
			// jQuery minimums
			'safari': [['<', 3]],
			'chrome': [['<', 3]],
			'netscape': [['<', 9]],
			'blackberry': false,
			'ipod': false,
			'iphone': false
		}

This also makes obvious that we can drop some of those items -- the jQuery minimum numbers don't need to be checked if we're already not loading any of this JS because jQuery won't be supported. :)


Version: 1.20.x
Severity: enhancement

Details

Reference
bz32188
TitleReferenceAuthorSource BranchDest Branch
Update(schema) anonymous column on tunnels tablerepos/mediawiki/services/ipoid!34tsepothoabalaT341880main
Customize query in GitLab

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 12:00 AM
bzimport set Reference to bz32188.
bzimport added a subscriber: Unknown Object (MLST).
Krinkle set Security to None.
Krinkle removed a subscriber: Unknown Object (MLST).

I have made the required changes and created a pull request to the original directory here: https://github.com/wikimedia/jquery-client

Need someone to review it. If any changes were to be made to the pull request, kindly comment here or you can also mail me at gauravgrover95@gmail.com
Thank You

Please link to your pull request. Thanks!

Regarding the WikiEditor use case, I think we can seriously consider removing the browser sniffing from that extension. It is almost (if not entirely) obsoleted by the startup module requirements for modern run-time. Meaning, it never returns false. All browsers unsupported by WikiEdotr are also unsupported by MediaWiki's modern client-side JavaScript.

https://github.com/wikimedia/jquery-client/pull/4

@Gauravgrover95: I am resetting the assignee of this task because there has not been progress lately (please correct me if I am wrong!).
Resetting the assignee avoids the impression that somebody is already working on this task. It also allows others to potentially work towards fixing this task.
Please claim this task again when you plan to work on it (via Add Action...Assign / Claim in the dropdown menu) - it would be welcome! Thanks for your understanding!

Krinkle renamed this task from Replace $.client.test() with $.client.isBlacklisted() to Rename $.client.test() to $.client.isBlacklisted().Oct 9 2017, 10:15 PM
Krinkle renamed this task from Rename $.client.test() to $.client.isBlacklisted() to Rename $.client.test() to $.client.isRejected().Sep 4 2020, 2:38 PM
Krinkle moved this task from Backlog to Enhancement on the jQuery-Client board.
Aklapper changed the subtype of this task from "Task" to "Feature Request".Feb 4 2022, 12:24 PM
Aklapper removed a subscriber: TrevorParscal.

As I understand it the methods we have cover most needs, and we don't plant to expand this further but instead want to discourage user agent sniffing.

The original use case most likely no longer applies as we no longer support most browsers we supported back then. If a similar use case does still exist, I would recommend handling it locally within your code by calling $.client.profile() and evaluating it how you see fit, which we expose for this reason, for custom needs.