SpecialJavaScriptTest: Add export feature
authorTimo Tijhof <krinklemail@gmail.com>
Tue, 2 Dec 2014 21:48:21 +0000 (21:48 +0000)
committerTimo Tijhof <krinklemail@gmail.com>
Mon, 5 Jan 2015 17:59:33 +0000 (17:59 +0000)
commitba50b32556fa1f2983c80cc6c06b5908f46f7cf4
tree3fe5c34c40ea7c793f27ea24af1197d7f78417c1
parentd9360b5fccd65afe25eb32dd9a01efe92fd7092f
SpecialJavaScriptTest: Add export feature

Add an 'export' subpage to SpecialJavaScriptTest which allows
one to request a self-sufficient JavaScript payload that will
bootstrap a ResourceLoader client and load the test suites.

This is needed for using Karma (which only loads JavaScript,
no full html pages). As such elements from the Skin and OutputPage
will not exist. While all QUnit tests in MediaWiki core and
most extensions I've seen already use #qunit-fixture, this is
now required. This to prevent leakage of elements from one
test to another, but it also prevents tests from depending
on elements provided by the server.

While the Karma setup is still in the pipeline (might land before
this commit loses WIP status), for now this can be tested via
the 'Special:JavaScriptTest/qunit/plain' subpage.

Refactor:
* Use HTTP status code 404 in the response for "noframework".
* Simplify HTML footprint by using <div id="qunit"> instead of
  hardcoding the full structure. This feature was added to QUnit
  since v1.3.0 (Feb 2012), we're using v1.14.0 (Jan 2014).
  QUnit's header is automatically derived from document.title.
* Remove redundant addModules() for 'test.mediawiki.qunit.testrunner'.
  This is already added by default.
* Move allowClickjacking() call so that it applies to other modes
  as well. The exported javascript needs to have wgBreakFrame set
  to false so that test runners can frame it.
* Change mediawiki.special.javaScriptTest to not depend on QUnit.
  It caused QUnit to load on error pages. And in theory the page
  is suited for other frameworks and shouldn't load QUnit this way.

Bug: T74063
Change-Id: I3d4d0df43bb426d9579eb0349b8b5477281a7cfc
includes/OutputPage.php
includes/specials/SpecialJavaScriptTest.php
languages/i18n/en.json
languages/i18n/qqq.json
resources/Resources.php
resources/src/mediawiki.special/mediawiki.special.javaScriptTest.js
tests/qunit/QUnitTestResources.php