mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
update components
This commit is contained in:
parent
abf163fb4a
commit
b385aa2d95
22 changed files with 368 additions and 90 deletions
|
@ -61,10 +61,13 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
|||
});
|
||||
}
|
||||
|
||||
function makeAbsoluteUrl(path) {
|
||||
return window.location.protocol + '//' + window.location.host + path;
|
||||
}
|
||||
|
||||
// A window.history.replaceState wrapper that's smart about baseURI.
|
||||
function replaceState(url) {
|
||||
window.history.replaceState(
|
||||
{}, '', window.location.protocol + '//' + window.location.host + url);
|
||||
function replaceState(path) {
|
||||
window.history.replaceState({}, '', makeAbsoluteUrl(path));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -164,6 +167,77 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
|||
assertHaveSameUrls(urlElem, otherUrlElem);
|
||||
});
|
||||
});
|
||||
suite('when intercepting links', function() {
|
||||
|
||||
/**
|
||||
* Clicks the given link while an iron-location element with the given
|
||||
* urlSpaceRegex is in the same document. Returns whether the
|
||||
* iron-location prevented the default behavior of the click.
|
||||
*
|
||||
* No matter what, it prevents the default behavior of the click itself
|
||||
* to ensure that no navigation occurs (as that would interrupt
|
||||
* running and reporting these tests!)
|
||||
*/
|
||||
function isClickCaptured(anchor, urlSpaceRegex) {
|
||||
var defaultWasPrevented;
|
||||
function handler(event) {
|
||||
expect(event.target).to.be.eq(anchor);
|
||||
defaultWasPrevented = event.defaultPrevented;
|
||||
event.preventDefault();
|
||||
expect(event.defaultPrevented).to.be.eq(true);
|
||||
}
|
||||
window.addEventListener('click', handler);
|
||||
var ironLocation = fixture('Solo');
|
||||
if (urlSpaceRegex != null) {
|
||||
ironLocation.urlSpaceRegex = urlSpaceRegex;
|
||||
}
|
||||
document.body.appendChild(anchor);
|
||||
anchor.click();
|
||||
document.body.removeChild(anchor);
|
||||
window.removeEventListener('click', handler);
|
||||
return defaultWasPrevented;
|
||||
}
|
||||
|
||||
test('simple link to / is intercepted', function() {
|
||||
var anchor = document.createElement('a');
|
||||
if (document.baseURI !== window.location.href) {
|
||||
anchor.href = makeAbsoluteUrl('/');
|
||||
} else {
|
||||
anchor.href = '/';
|
||||
}
|
||||
|
||||
expect(isClickCaptured(anchor)).to.be.eq(true);
|
||||
});
|
||||
|
||||
test('link that matches url space is intercepted', function() {
|
||||
var anchor = document.createElement('a');
|
||||
anchor.href = makeAbsoluteUrl('/foo');
|
||||
|
||||
expect(isClickCaptured(anchor, '/fo+')).to.be.eq(true);
|
||||
});
|
||||
|
||||
test('link that doesn\'t match url space isn\'t intercepted', function() {
|
||||
var anchor = document.createElement('a');
|
||||
anchor.href = makeAbsoluteUrl('/bar');
|
||||
|
||||
expect(isClickCaptured(anchor, '/fo+')).to.be.eq(false);
|
||||
});
|
||||
|
||||
test('link to another domain isn\'t intercepted', function() {
|
||||
var anchor = document.createElement('a');
|
||||
anchor.href = 'http://example.com/';
|
||||
|
||||
expect(isClickCaptured(anchor)).to.be.eq(false);
|
||||
});
|
||||
|
||||
test('a link with target=_blank isn\'t intercepted', function() {
|
||||
var anchor = document.createElement('a');
|
||||
anchor.href = makeAbsoluteUrl('/');
|
||||
anchor.target = '_blank';
|
||||
|
||||
expect(isClickCaptured(anchor)).to.be.eq(false);
|
||||
})
|
||||
});
|
||||
|
||||
suite('supports doing synchronous redirection', function() {
|
||||
test('of the hash portion of the URL', function() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue