Page MenuHomePhabricator

QUnit test fails on REL1_26: Exception in mediawiki.widgets.CategorySelector 'TypeError: Expecting a function in instanceof check, but got undefined', TypeError{}'
Closed, ResolvedPublic

Description

A patch proposed to MediaWiki REL1_26 fails the qunit tests ( https://gerrit.wikimedia.org/r/#/c/265510/ ) with:

00:02:24.293 Chromium 48.0.2564 (Ubuntu 0.0.0) LOG: 'Exception in module-execute in module mediawiki.widgets.CategorySelector:'
00:02:24.293 Chromium 48.0.2564 (Ubuntu 0.0.0) ERROR: 'TypeError: Expecting a function in instanceof check, but got undefined', TypeError{}

A previous run of the job had Chromium 47 and passed just fine. I am suspecting the test/feature breaks with Chromium 48.

That prevent changes from being merged in REL1_26 :-(

Event Timeline

hashar raised the priority of this task from to Needs Triage.
hashar updated the task description. (Show Details)
hashar added a project: MediaWiki-Core-Tests.
hashar added subscribers: hashar, matmarex, Prtksxna and 2 others.

I proposed a backport for REL1_26 that tweak the Karma runner output, hoping it can help the diagnostic. https://gerrit.wikimedia.org/r/#/c/267535/ We will see what the qunit job console reports there.

The last proxied request is:

DEBUG [proxy]: proxying request
  /jenkins-mediawiki-extensions-qunit-28539/load.php?debug=false&lang=en&modules=jquery.effects.blind%2Ccore%7Cjquery.ui.autocomplete%2Ccore%2Cmenu%2Cposition%2Cwidget%7Cjquery.ui.core.styles&skin=fallback&version=dd686ce0f3de
to localhost:9412

Expanded:

/jenkins-mediawiki-extensions-qunit-28539/load.php?debug=false
lang=en
modules=jquery.effects.blind%2Ccore%7Cjquery.ui.autocomplete%2Ccore%2Cmenu%2Cposition%2Cwidget%7Cjquery.ui.core.styles
skin=fallback
version=dd686ce0f3de

00:02:24.293 Chromium 48.0.2564 (Ubuntu 0.0.0) LOG: 'Exception in module-execute in module mediawiki.widgets.CategorySelector:'
00:02:24.293 Chromium 48.0.2564 (Ubuntu 0.0.0) ERROR: 'TypeError: Expecting a function in instanceof check, but got undefined', TypeError{}

Well, that's a pretty lame error message, but using my psychic powers I determined that it happens here:

OO.inheritClass( CategorySelector, OO.ui.CapsuleMultiSelectWidget );

Presumably, OO.inheritClass( targetFn, originFn ) is called, but OO.ui.CapsuleMultiSelectWidget is undefined, so when it does a targetFn.prototype instanceof originFn check, originFn is undefined and thus this error.

Which means that things are not being loaded correctly. Probably a network issue or a ResourceLoader issue, rather than JavaScript issue in CategorySelector. It has all the dependencies set up correctly.

@Krinkle can I add you to task please since you may know why it is doing this. This could be fixed in master but broken in REL1_26.

Paladox removed a subscriber: Krinkle.

I can't reproduce it locally with MediaWiki core REL1_26.

The extensions job uses these jobs:

Dependencies:
AbuseFilter Babel Cards CheckUser CirrusSearch Cite cldr ConfirmEdit Echo Elastica EventLogging Flow Gather GlobalCssJs GuidedTour JsonConfig MobileApp MobileFrontend MwEmbedSupport ParserFunctions PdfHandler SandboxLink SpamBlacklist Thanks TimedMediaHandler UniversalLanguageSelector VisualEditor Wikidata ZeroBanner ZeroPortal
Result: FAILURE

I've narrowed it down by re-building the mediawiki-extensions-qunit job with different values for the DEPENDENCIES environment variable.

Dependencies: Flow AbuseFilter CheckUser ConfirmEdit SpamBlacklist Echo EventLogging VisualEditor
Result: SUCCESS

Dependencies: Wikidata cldr Elastica GeoData Scribunto
Result: SUCCESS

Dependencies: ZeroPortal Echo JsonConfig MobileFrontend VisualEditor ZeroBanner
Result: SUCCESS

Dependencies: Babel Cards GlobalCssJs MobileApp ParserFunctions PdfHandler SandboxLink UniversalLanguageSelector EventLogging
Result: SUCCESS

Dependencies: CirrusSearch Elastica MwEmbedSupport TimedMediaHandler PdfHandler Cite
Result: SUCCESS

Dependencies: GuidedTour EventLogging
Result: SUCCESS

Dependencies: Gather MobileFrontend Echo VisualEditor
Result: SUCCESS

Dependencies: Thanks Echo Flow MobileFrontend
Result: SUCCESS

So.. not sure why it fails when they are all together.

After much inspection, the bug is not in any of the extensions. However it isn't triggered on a plain core run because mediawiki.widgets.CategorySelector doesn't have tests. It gets loaded (and fails) during the combined test because something else (probably VisualEditor, or UploadWizard) has tests and depends on mediawiki.widgets.CategorySelector.

The failure itself then:

00:02:24.293 Chromium 48.0.2564 (Ubuntu 0.0.0) LOG: 'Exception in module-execute in module mediawiki.widgets.CategorySelector:'
00:02:24.293 Chromium 48.0.2564 (Ubuntu 0.0.0) ERROR: 'TypeError: Expecting a function in instanceof check, but got undefined', TypeError{}

OO.inheritClass( CategorySelector, OO.ui.CapsuleMultiSelectWidget );

Presumably, OO.inheritClass( targetFn, originFn ) is called, but OO.ui.CapsuleMultiSelectWidget is undefined

This assumption was wrong. The error isn't coming from mw.widgets.CategorySelector.js, but from CategoryCapsuleItemWidget.

	'mediawiki.widgets.CategorySelector' => array(
		'scripts' => array(
			'resources/src/mediawiki.widgets/mw.widgets.CategoryCapsuleItemWidget.js',
			'resources/src/mediawiki.widgets/mw.widgets.CategorySelector.js',
		),
		'dependencies' => array(
			'oojs-ui',
			'mediawiki.api',
		)
		'targets' => array( 'desktop', 'mobile' ),
	),

Specifically:

	function ForeignTitle() {
		ForeignTitle.parent.apply( this, arguments );
	}
	OO.inheritClass( ForeignTitle, mw.Title );
                                       ^

And indeed. There is no dependency on mediawiki.Title.

Change 274876 had a related patch set uploaded (by Krinkle):
mediawiki.widgets.CategorySelector: Add missing dependency for ForeignApi and Title

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

Krinkle triaged this task as Unbreak Now! priority.

After fixing mediawiki.widgets.CategorySelector, another failure in REL1_26, which is that it still enforces QUnit expect(). And while most code still passes under that restriction, Wikibase does not. Somehow Wikibase's REL1_26 branch contains slightly newer code than the rest of REL1_26 (which wasn't caught at the time because Wikibase it wasn't in the extensions test group when REL1_26 got cut).

Removing that from testrunner.js in REL1_26 of MediaWiki core is easy but that didn't help because the VisualEditor extension, including lib/ve, including its testrunner, also sets QUnit.config.requireExpects = true;.

Had to create a REL1_26 branch for VisualEditor/VisualEditor (based on the lib/ve pointer from mediawiki/extensions/VisualEditor@REL1_26), create a patch here, and update the submodule.

After landing all the following:

.. REL1_26 could've been passing – if it weren't for Wikibase (again). See T128828.

This task is basically resolved (the fix is in Gerrit) but can't be merged until T128828 is fixed, too.

Krinkle changed the task status from Open to Stalled.Mar 4 2016, 3:03 AM
Krinkle removed Krinkle as the assignee of this task.
Krinkle lowered the priority of this task from Unbreak Now! to High.
Krinkle subscribed.

Change 274775 had a related patch set uploaded (by Krinkle):
[DONT MERGE] Debugging for T125335

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

Krinkle renamed this task from Chromium 48 breaks qunit test with: Exception in mediawiki.widgets.CategorySelector 'TypeError: Expecting a function in instanceof check, but got undefined', TypeError{}' to QUnit test fails on REL1_26: Exception in mediawiki.widgets.CategorySelector 'TypeError: Expecting a function in instanceof check, but got undefined', TypeError{}'.Mar 4 2016, 6:58 PM

Change 274775 abandoned by Krinkle:
[DONT MERGE] Debugging for T125335

Reason:
Obsolete

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

I disabled the Wikidata build in the 1.26 branch to unblock this.

Krinkle closed this task as Resolved.EditedMar 14 2016, 6:10 PM
Krinkle claimed this task.

Thanks. I don't think it was ever explicitly added to REL1_26. Rather, it was added to the generic job for "grouped extension" testing. Which runs on older branches as well.

Change 274876 merged by jenkins-bot:
mediawiki.widgets.CategorySelector: Add missing dependency for ForeignApi and Title

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