From: Timo Tijhof Date: Thu, 31 Mar 2016 20:18:14 +0000 (+0100) Subject: Remove skin mode of Special:JavaScriptTest X-Git-Tag: 1.31.0-rc.0~7377^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20%20%20%24self2%20.%20%20%20%22&var_mode_affiche=boucle?a=commitdiff_plain;h=0f9e4ca0fb7cee127e86e7f1844da4c42df5a95e;p=lhc%2Fweb%2Fwiklou.git Remove skin mode of Special:JavaScriptTest Leaving behind only the so-called "plain" mode. Also removed related unused messages (follows-up 6b758fc). The execute() method continues to enforce 404 Not Found for arbitrary subpage urls so that we keep the door open to add other sub resources or test frameworks in the future. Bug: T131389 Change-Id: I4c22666fb98e54c47ed1b4d12776af6fc43ee473 --- diff --git a/includes/specials/SpecialJavaScriptTest.php b/includes/specials/SpecialJavaScriptTest.php index 37dba53774..5d36a3c676 100644 --- a/includes/specials/SpecialJavaScriptTest.php +++ b/includes/specials/SpecialJavaScriptTest.php @@ -25,12 +25,6 @@ * @ingroup SpecialPage */ class SpecialJavaScriptTest extends SpecialPage { - /** - * @var array Supported frameworks. - */ - private static $frameworks = [ - 'qunit', - ]; public function __construct() { parent::__construct( 'JavaScriptTest' ); @@ -42,102 +36,33 @@ class SpecialJavaScriptTest extends SpecialPage { $this->setHeaders(); $out->disallowUserJs(); - if ( $par === null ) { - // No framework specified - // If only one framework is configured, redirect to it. Otherwise display a list. - if ( count( self::$frameworks ) === 1 ) { - $out->redirect( $this->getPageTitle( self::$frameworks[0] . '/plain' )->getLocalURL() ); - return; - } - $out->setStatusCode( 404 ); - $out->setPageTitle( $this->msg( 'javascripttest' ) ); - $out->addHTML( - $this->msg( 'javascripttest-pagetext-noframework' )->parseAsBlock() - . $this->getFrameworkListHtml() - ); - return; - } - - // Determine framework and mode - $pars = explode( '/', $par, 2 ); - - $framework = $pars[0]; - if ( !in_array( $framework, self::$frameworks ) ) { - // Framework not found - $out->setStatusCode( 404 ); - $out->addHTML( - '
' - . $this->msg( 'javascripttest-pagetext-unknownframework' ) - ->plaintextParams( $par )->parseAsBlock() - . '
' - . $this->getFrameworkListHtml() - ); - return; - } - // This special page is disabled by default ($wgEnableJavaScriptTest), and contains // no sensitive data. In order to allow TestSwarm to embed it into a test client window, // we need to allow iframing of this page. $out->allowClickjacking(); - if ( count( self::$frameworks ) !== 1 ) { - // If there's only one framework, don't set the subtitle since it - // is going to redirect back to this page - $out->setSubtitle( - $this->msg( 'javascripttest-backlink' ) - ->rawParams( Linker::linkKnown( $this->getPageTitle() ) ) - ); - } - // Custom actions - if ( isset( $pars[1] ) ) { - $action = $pars[1]; - if ( !in_array( $action, [ 'export', 'plain' ] ) ) { - $out->setStatusCode( 404 ); - $out->addHTML( - '
' - . $this->msg( 'javascripttest-pagetext-unknownaction' ) - ->plaintextParams( $action )->parseAsBlock() - . '
' - ); - return; - } - $method = $action . ucfirst( $framework ); - $this->$method(); + // Sub resource: Internal JavaScript export bundle for QUnit + if ( $par === 'qunit/export' ) { + $this->exportQUnit(); return; } - $method = 'view' . ucfirst( $framework ); - $this->$method(); - $out->setPageTitle( $this->msg( - 'javascripttest-title', - // Messages: javascripttest-qunit-name - $this->msg( "javascripttest-$framework-name" )->plain() - ) ); - } - - /** - * Get a list of frameworks (including introduction paragraph and links - * to the framework run pages) - * - * @return string HTML - */ - private function getFrameworkListHtml() { - $list = ''; - return $this->msg( 'javascripttest-pagetext-frameworks' )->rawParams( $list ) - ->parseAsBlock(); + // Unknown action + $out->setStatusCode( 404 ); + $out->setPageTitle( $this->msg( 'javascripttest' ) ); + $out->addHTML( + '
' + . $this->msg( 'javascripttest-pagetext-unknownaction' ) + ->plaintextParams( $par )->parseAsBlock() + . '
' + ); } /** @@ -152,37 +77,6 @@ class SpecialJavaScriptTest extends SpecialPage { return "
$summary
"; } - /** - * Run the test suite on the Special page. - * - * Rendered by OutputPage and Skin. - */ - private function viewQUnit() { - $out = $this->getOutput(); - - $modules = $out->getResourceLoader()->getTestModuleNames( 'qunit' ); - - $baseHtml = << -
- -HTML; - - $out->addHTML( $this->getSummaryHtml() . $baseHtml ); - - // The testrunner configures QUnit and essentially depends on it. However, test suites - // are reusable in environments that preload QUnit (or a compatibility interface to - // another framework). Therefore we have to load it ourselves. - $out->addHTML( ResourceLoader::makeInlineScript( - Xml::encodeJsCall( 'mw.loader.using', [ - [ 'jquery.qunit', 'jquery.qunit.completenessTest' ], - new XmlJsCode( - 'function () {' . Xml::encodeJsCall( 'mw.loader.load', [ $modules ] ) . '}' - ) - ] ) - ) ); - } - /** * Generate self-sufficient JavaScript payload to run the tests elsewhere. * diff --git a/languages/i18n/en.json b/languages/i18n/en.json index b7c0ac60c6..579e9b89f4 100644 --- a/languages/i18n/en.json +++ b/languages/i18n/en.json @@ -2579,14 +2579,7 @@ "import-logentry-interwiki": "transwikied $1", "import-logentry-interwiki-detail": "$1 {{PLURAL:$1|revision|revisions}} imported from $2", "javascripttest": "JavaScript testing", - "javascripttest-backlink": "< $1", - "javascripttest-title": "$1", - "javascripttest-pagetext-noframework": "This page is reserved for running JavaScript tests.", - "javascripttest-pagetext-unknownframework": "Unknown testing framework \"$1\".", "javascripttest-pagetext-unknownaction": "Unknown action \"$1\".", - "javascripttest-pagetext-frameworks": "Please choose one of the following testing frameworks: $1", - "javascripttest-pagetext-skins": "Choose a skin to run the tests with:", - "javascripttest-qunit-name": "QUnit", "javascripttest-qunit-intro": "See [$1 testing documentation] on mediawiki.org.", "accesskey-pt-userpage": ".", "accesskey-pt-anonuserpage": ".", diff --git a/languages/i18n/qqq.json b/languages/i18n/qqq.json index 379fe797d6..28c02cb461 100644 --- a/languages/i18n/qqq.json +++ b/languages/i18n/qqq.json @@ -2755,14 +2755,7 @@ "import-logentry-interwiki": "{{ignored}}This is a ''logentry'' message only used on IRC. Parameters:\n* $1 - page title", "import-logentry-interwiki-detail": "Used as success message and log entry. Parameters:\n* $1 - number of succeeded revisions\n* $2 - interwiki name\nSee also:\n* {{msg-mw|Import-logentry-upload-detail}}", "javascripttest": "Title of the special page [[Special:JavaScriptTest]].\n\nSee also:\n* {{msg-mw|Javascripttest|title}}\n* {{msg-mw|Javascripttest-pagetext-noframework|summary}}\n* {{msg-mw|Javascripttest-pagetext-unknownframework|error message}}", - "javascripttest-backlink": "{{optional}}\nUsed as subtitle in [[Special:JavaScriptTest]]. Parameters:\n* $1 - page title", - "javascripttest-title": "{{Ignore}}", - "javascripttest-pagetext-noframework": "Used as summary when no framework specified.\n\nSee also:\n* {{msg-mw|Javascripttest|title}}\n* {{msg-mw|Javascripttest-pagetext-noframework|summary}}\n* {{msg-mw|Javascripttest-pagetext-unknownframework|error message}}", - "javascripttest-pagetext-unknownframework": "Error message when given framework ID is not found. Parameters:\n* $1 - the ID of the framework\nSee also:\n* {{msg-mw|Javascripttest|title}}\n* {{msg-mw|Javascripttest-pagetext-noframework|summary}}\n* {{msg-mw|Javascripttest-pagetext-unknownframework|error message}}", "javascripttest-pagetext-unknownaction": "Error message when url specifies an unknown action. Parameters:\n* $1 - the action specified in the url.", - "javascripttest-pagetext-frameworks": "Parameters:\n* $1 - frameworks list which contain a link text {{msg-mw|Javascripttest-qunit-name}}", - "javascripttest-pagetext-skins": "Used as label in [[Special:JavaScriptTest]].", - "javascripttest-qunit-name": "{{Ignore}}", "javascripttest-qunit-intro": "Used as summary. Parameters:\n* $1 - the configured URL to the documentation\nSee also:\n* {{msg-mw|Javascripttest-qunit-heading}}", "accesskey-pt-userpage": "{{doc-accesskey}}\nSee also:\n\n* {{msg-mw|Accesskey-pt-userpage}}\n* {{msg-mw|Tooltip-pt-userpage}}", "accesskey-pt-anonuserpage": "{{doc-accesskey}}",