Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 10
0.00% covered (danger)
0.00%
0 / 3
CRAP
0.00% covered (danger)
0.00%
0 / 1
SpecialEditCheckHeadless
0.00% covered (danger)
0.00%
0 / 10
0.00% covered (danger)
0.00%
0 / 3
12
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 isListed
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 execute
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace MediaWiki\Extension\VisualEditor;
4
5use MediaWiki\Skin\SkinFactory;
6use MediaWiki\SpecialPage\SpecialPage;
7
8class SpecialEditCheckHeadless extends SpecialPage {
9
10    private SkinFactory $skinFactory;
11
12    public function __construct( SkinFactory $skinFactory ) {
13        parent::__construct( 'EditCheckHeadless' );
14        $this->skinFactory = $skinFactory;
15    }
16
17    /**
18     * @inheritDoc
19     */
20    public function isListed() {
21        return false;
22    }
23
24    /**
25     * @inheritDoc
26     */
27    public function execute( $subPage ) {
28        $this->setHeaders();
29
30        $out = $this->getOutput();
31        $out->setPageTitle( '' );
32
33        // This page is only ever loaded in a headless browser to run edit checks
34        // in JavaScript; it renders no visible UI. Suppress as much of the normal
35        // page output as possible to speed up load:
36        // - Use the minimal "apioutput" skin (as core does for API HTML output) to
37        //   drop the sidebar, personal tools, footer, logo and skin CSS while still
38        //   emitting the ResourceLoader bootstrap so our module's JS can run.
39        // - Disallow user JS
40        // - Tell crawlers not to index it.
41        $this->getContext()->setSkin( $this->skinFactory->makeSkin( 'apioutput' ) );
42        $out->disallowUserJs();
43        $out->setRobotPolicy( 'noindex,nofollow' );
44
45        $out->addModules( 'ext.visualEditor.editCheck.headless' );
46    }
47}