Force a content model on the title used by HooksTest, so that
calls to getPageLanguage() won't end up hitting the DB
Only happens when the Flow extension is enabled
Change-Id: Ie4769f972c26e48a216e4546a584893a8b47eb19
Use the eslint rule
"no-var": "error"
in resources/.eslintrc.json and in .eslintrc.json
to require the use of `const` and `let` instead of `var`.
Bug: T337102
Change-Id: I3b3d6d426966a97c13f62494443f62bd5b790920
This test was leaving behind the black overlay, obscuring the test
results interface. Upon closer inspection, it appears not one part
of this test is doing anything that actually works.
* Assertion 1: `viewer.isOpen === false`
This is the initial and default state. Not essential for the test,
but so far so good.
* Prep for Assertion 2 & 3:
We call loadImageByTitle. One might think that this will set isOpen
to true, but, this isn't asserted. If one did, the test would fail,
because loadImageByTitle returns early from its first branch
in `!this.thumbs.length` and is thus a no-op, and adds nothing to
the test.
We set `location.hash = 'Foo'`.
* Assertion 2: `location.hash === '#Foo'`
Assertion 3: `viewer.isOpen === false`
Assertion 2 is meaningless because handling of hash changes appears
to be asynchronous. Perhaps not always, but at least the indirection
used in this codebase makes it async. Hence, the fact that it is
correctly normalised to '#Foo' is meaningless as the popstate
and hashchange event handler haven't been processed yet. If they
were, it would still be meaningless since viewer.isOpen was never
true in the first place and MMV's event handlers for popstate/hashchange
are guarded by `isOpen`.
* Prep for Assertion 4: location.hash = Bar
* Assertion 4: `location.hash === '#Bar'`
Idem.
* Prep for Assertion 5: Replace the viewer.loadImageByTitle function
with a function that performs a nested assertion.
This function is never called and its assertion never reached.
This is a textbook example why assertions should never be
nested. If you rewrite this in following with the advice from
<https://api.qunitjs.com/assert/verifySteps/>, we find that
the array is in fact empty by the end of the test() function.
```js
var seen = [];
viewer.loadImageByTitle = function ( title ) {
// assert.strictEqual( … );
seen.push( title.getPrefixedText() );
};
location.hash = …;
location.hash = …;
location.hash = …;
location.hash = …;
assert.deepEqual( seen, [ 'File:' + imageSrc' } );
// Actual: []
```
== Misc notes ==
The test ends with "#/media/File:Foo bar.jpg" set on location.hash,
and the black overlay covering the page. It seems that the hashchange
are async, and that the first in a given event loop tick "wins", with
later ones being ignored. Observing this with debugger/breakpoints is
hard given that each pause results in the effect not being observable.
console.log(location.href) at the end of the test shows hash='#',
but placing a debugger at the end of the test results in the hash
being "#/media/…" instead.
Exprienced in Firefox 117 on macOS.
Change-Id: Ib37bec1b3e67fcab1da89d23381a3adbb6312827
This makes the test report inaccessible in the browser. I'm adding
it at the module level given that nearly all test cases in this
file trigger it:
* "Progress"
* "Progress when switching images"
* "New image loaded while another one is loading"
* "Events are not trapped after the viewer is closed"
* "document.title"
```
- QUnit.module( 'mmv', QUnit.newMwEnvironment() );
+ QUnit.module( 'mmv', QUnit.newMwEnvironment( {
+ beforeEach: function () {
+ this.sandbox.stub( require( 'mediawiki.router' ), 'back', function () {
+ console.log( QUnit.config.current.testName );
+ console.trace();
+ } );
+ }
+ } ) );
```
Change-Id: I0cb7ed6c76d5547bcef9c183c9305b6fd08ec9eb
Avoid creating of Title object to get the "fixed special name" (which is
the localized name) and compare that against the local name of the
current page, just use the SpecialPageFactory to get the canonical name
(which is the english internal name, not the english visible name) and
compare against the list of canonical allowed pages (adjust the existing
list to the canonical names, that are "old" names in different cases)
Change-Id: Ia6f6574bf6e65c75f8977ff016feda6ecdca3776
Use localstorage to store MMV preference for anon and temp users,
use regular user preference for non-temp accounts only
For embed default to wikitext for temp and regular users, html
for anon users
Bug: T340534
Change-Id: Ic19e8a6b6fbdeb2c86be14a33a306dd0f3088b1b
Since MediaWiki change 6f9d4829b2fefc98a1969bb8f7ab3d04ef0268fe
mw.SafeStorage sometimes calls removeItem() before calling setItem(),
so we need to mock it as well.
Bug: T340069
Change-Id: Ife6c4cc032689bb75e572d7936ce33afa76cf396
- mediawiki.router is available inside mmv.bootstrap so move
the handlers into the bootstrap file
- Remove direct loading of images from mmv.js instead modify
event handlers to modify the location which will trigger the loading of
the image
- Copy what we previously did in MobileFrontend (Bartosz's idea)
to allow page refreshing and escaping overlay on page load.
- Remove some no longer relevant tests
Bug: T236591
Change-Id: Ie5d33fca5174db58380a63f5cf97f44e5df10d42
The
progressBar: {
hide: this.sandbox.stub()
}
fixes the following exception in the JavaScript console:
jQuery.Deferred exception: progressBar.hide is not a function MMVP.setupProgressBar
The
router: {
checkRoute: function () {}
}
fixes the following exception in the JavaScript console:
jQuery.Deferred exception: viewer.router is undefined
Change-Id: Ia7658937ebdbb77a5889d6462f7706bb2fd4e08f
The response of prop=imageinfo is now an array instead of an object.
Therefor it is not needed to interate over the elements anymore.
The array contains exact one element if one title is used in the query.
The function getNormalizedTitle not needed anymore because the
requested title is always the first element of the array.
Change-Id: I7a226d3950615a2152c3f55127b218cac2d21fcc
The MediaViewer and MultimediaViewer* instruments were disabled circa
October 2021 in Ie7dd8739efc.
This patch removes those instruments and any supporting code and data.
Notably, this patch does not remove the mw.mmv.logging.ViewLogger
instrument, which is responsible for logging image views.
Bug: T310890
Change-Id: I97d41be93849b2ae9d1adba6660546ea716657fd
* Declare variables inline, as per the current code conventions.
* Use `assert.true()` or `assert.false()` in a few places.
* Clarify some test names and simplify some surrounding code.
Change-Id: Id0bca942e34564b9c011e89c0b2298cbb4f8a582
My browser is configured with en-GB as its locale. This meant that
when qqx was passed down, it fell back to my browser's default locale
and thus made the tests fail, as the expected data was set against
lang=en.
Ironically, MMV actually prefers the en-GB date format, and outside
tests even replaces 'en' with 'en-GB' when formatting dates in the
user interface. It was only in the tests that it asserted the 'en'
format that would otherwise never be used by MMV.
Ironically, the reason my locale is affecting the test is because
we switched from hardcoded lang=en to hardcoded lang=qqx which is
meant to disable any influence from localisation. However, when
passed to browser-native Intl API, qqx is not valid and thus
caused us to not have a hardcoded 'en' but a completely variable
UI language based on the developer's browser settings.
Bug: T250045
Change-Id: I94ad25cc7060ac5e9db41c6b6767aa9fd687a0db
Currently for files from foreign repositories, the "More details"
button always points to the foreign description page, regardless of
whether a local description page exists. That is a bit unintuitive,
as the local description page often contains additional info (like
categories) that may be useful for the user.
This patch changes the behavior of the button to link to a local
description page if available.
Change-Id: I7db609a4dda42f28ef913ad6d4256fb5adabeb89
This framework has been legacy / unsupported for four years now. It's
time to admit defeat. Someone keen can re-use these tests from git in
an effort to write into JavaScript in the future
Test running removed from CI in 690d5a909.
Bug: T180226
Change-Id: Id952fe14f608d0b185ed1170b990192b0de575d3
The job has been failing for months for macOS. Tests are not providing
any value.
Ruby Selenium framework has been deprecated since 2017. We are removing
support for it from CI.
Bug: T214389
Bug: T220035
Change-Id: I4fef826a7ac1e7b2d260b1bf8f5d42e3f214b07d
Results in small UI changes, but allows us to delete a lot
of code duplication.
Depends-On: I9049f5a1c0d88680fc4a174e390dd08e27c0eee2
Change-Id: Iebe7bdc8a026b929a35e823d8107d90e7bb62b82
What MultiMediaViewer does is re-using the small thumbnail <img> that
is already present on the page, cloning it, blowing the size up, and
using it as a "placeholder thumbnail". The moment the bigger image
finished loading, it replaces the placeholder.
The issue here is that the cloning includes class names like the
<img class="thumbimage"> on every [[File:…|thumb]] image. This shows a
gray border. The cloned DOM node in MultiMediaViewer shows this gray
border around the placeholder for a short time. This can be distracting.
Change-Id: Ie83427fab478b6568731b9a0b1f7dbbcc6d5b0fb
These modules are deprecated and will be removed, see parent task for
details and deprecation information.
Bug: T223284
Change-Id: I2532e20659a59cdd036a7d8ad5a040ae136848f5
Sauce labs removed support for OSX 10.9, so we've seen failures in the
browser tests for a while apparently.
The generic "macos" should just work, and is sufficient for our testing
needs.
Bug: T214389
Change-Id: I01c1e9e03dc5b658aa3e2b3ee6a7b5f503488f97
* Deletes the mmv.model.EmbedFileInfo class file and its test file
* Updates the extension.json and MultimediaViewerHooks.php files to reflect
these deletions (by removing entries from dependency lists)
* Refactors all instances of `new mmv.model.EmbedFileInfo()` to instead use a
POJO with appropriate properties. Conditional assignment is used for the
caption and alt properties if there is any chance they won't be available, to
keep from adding props with falsy values.
* Refactors JSDoc method annotations so that `@param` tags expecting an
EmbedFileInfo instance now expect an object; relevant properties of this
object and their types have been added to the method annotations as well.
Bug: T77320
Change-Id: Ie9f5f24136f4b73000259685474ce4d765a3ccd3
When an svg file is requested, returns the 1024px file and displays at
max possible size
Bug: T71237
Change-Id: I797794d1f9b1aa66cbb9bd9fec57274554292fb1
As we already allow visual markup in captions, I see no reason to not
whitelist sup and sub. These elements are even allowed in the
displaytitle whitelist for articles, so seems appropriate to have them
for media captions as well.
Bug: T186844
Change-Id: I4339ee85d139301770a4e15650c9dc0d64c136cd
Media Viewer tries to detect the file name from the thumbnail name.
That can break for the main image of a file page, which is normally
a preview (ie. a normal thumbnail) but for unhandled types it can
be some asset (such as a PDF icon).
Bug: T137477
Change-Id: Ie6b23d7ef213087971b320460129910f2efd248e
Test failure from jenkins:
https://integration.wikimedia.org/ci/job/mwext-mw-selenium-jessie/6608/console
Background: # features/mmv.download.feature:4
Given I am viewing an image using MMV # features/step_definitions/mmv_steps.rb:21
expected "https://creativecommons.org/licenses/by-sa/3.0" to match /^http:\/\/creativecommons.org\/licenses\/by-sa\/3.0$/
Diff:
@@ -1,2 +1,2 @@
-/^http:\/\/creativecommons.org\/licenses\/by-sa\/3.0$/
+"https://creativecommons.org/licenses/by-sa/3.0"
(RSpec::Expectations::ExpectationNotMetError)
./features/step_definitions/mmv_steps.rb:126:in `check_elements_in_viewer_for_image2'
./features/step_definitions/mmv_steps.rb:73:in `block (2 levels) in <top (required)>'
./features/step_definitions/mmv_steps.rb:70:in `/^the image metadata and the image itself should be there$/'
./features/step_definitions/mmv_steps.rb:25:in `/^I am viewing an image using MMV$/'
features/mmv.download.feature:5:in `Given I am viewing an image using MMV'
Scenario: Download menu can be opened # features/mmv.download.feature:7
When I click the download icon # features/step_definitions/mmv_download_steps.rb:8
Then the download menu should appear # features/step_definitions/mmv_download_steps.rb:54
Change-Id: I6feda65ca8ff2bc8f790eaaac8f63e1feafcbdfd
This is an old library that is broken in Chrome 61.
Rather than updating it we can just use $(window).scrollTop/Left
which works in all the browsers we currently support.
Fix MPSP.toggle to return a promise, instead of a deferred
(although this return value is not used yet).
Bug: T173618
Change-Id: Iaec56debbb808bd95cf65c1ebfe22bdf0116da68
* Removed deprecated testCount, which is no longer supported in this way.
It's only useful when wanting to explicitly expect 0 assertions (normally
considered an error).
* Replaced use of testCount = 0, with assert.expect( 0 ).
Change-Id: I8fe82032d3af2a1ad2ed7febdb90a95d56dd3fc4
Meanwhile I also updated a few places where a non-string was
passed to/expected from localStorage - this could’ve led to
inconsistencies because localStorage stringifies everything.
And I also removed CP.canSetMediaViewerEnabledOnClick, which
was no longer used anywhere except for a test case.
Bug: T137777
Change-Id: I21ad4ba15ca751bb03e5e2c523d09a45c0444ccf