From 870d3a6532e66ecfa1fb1127b44fed20cc152570 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Wed, 28 Feb 2018 17:45:45 -0800 Subject: [PATCH] resourceloader: Simplify load.mock.php by removing includes dependency It previously depended on Xml.php for Xml::encodeJsCall, which in turn depends on FormatJson. Other Xml.php methods also depend on Sanitizer, but that was carefully not triggered. Avoid both of these by simply constructing the string inline, and using json_encode() directly for the one variable parameter. Also, fix the names of one of the ResourceLoaderTest cases for dotless module names. It claims to have been added to cover a regression fixed in r88706, but that commit seems rather unrelated. A bit of searching revealed as the relevant commit instead. Bug: T188076 Change-Id: I04851d0355227f3a6b79b8d41a51d4beadce0e80 --- tests/phpunit/includes/resourceloader/ResourceLoaderTest.php | 2 +- tests/qunit/data/load.mock.php | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/tests/phpunit/includes/resourceloader/ResourceLoaderTest.php b/tests/phpunit/includes/resourceloader/ResourceLoaderTest.php index 0bc558ad62..4e9f5399c5 100644 --- a/tests/phpunit/includes/resourceloader/ResourceLoaderTest.php +++ b/tests/phpunit/includes/resourceloader/ResourceLoaderTest.php @@ -261,7 +261,7 @@ class ResourceLoaderTest extends ResourceLoaderTestCase { 'jquery.foo,bar|jquery.ui.baz,quux', ], [ - 'Regression fixed in r88706 with dotless names', + 'Regression fixed in r87497 (7fee86c38e) with dotless names', [ 'foo', 'bar', 'baz' ], 'foo,bar,baz', ], diff --git a/tests/qunit/data/load.mock.php b/tests/qunit/data/load.mock.php index 671bdf1fc2..23fb4c912c 100644 --- a/tests/qunit/data/load.mock.php +++ b/tests/qunit/data/load.mock.php @@ -24,9 +24,6 @@ */ header( 'Content-Type: text/javascript; charset=utf-8' ); -require_once __DIR__ . '/../../../includes/json/FormatJson.php'; -require_once __DIR__ . '/../../../includes/Xml.php'; - $moduleImplementations = [ 'testUsesMissing' => " mw.loader.implement( 'testUsesMissing', function () { @@ -66,7 +63,7 @@ if ( isset( $_GET['modules'] ) ) { if ( isset( $moduleImplementations[$module] ) ) { $response .= $moduleImplementations[$module]; } else { - $response .= Xml::encodeJsCall( 'mw.loader.state', [ $module, 'missing' ], true ); + $response .= 'mw.loader.state(' . json_encode( $module ) . ', "missing" );' . "\n"; } } } -- 2.20.1