From 413ef2fbc8280e70a5880880e33a24104b3c0857 Mon Sep 17 00:00:00 2001 From: Alexander Marks Date: Tue, 7 May 2019 11:37:53 -0700 Subject: [PATCH] Upstreaming cl/245273850 --- test/unit/resolveurl.html | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/test/unit/resolveurl.html b/test/unit/resolveurl.html index 26d708b682..1794c28725 100644 --- a/test/unit/resolveurl.html +++ b/test/unit/resolveurl.html @@ -170,6 +170,38 @@ assert.equal(actual, expected); }); + test('resolveUrl when called with relative url and a bad baseURI', function () { + const el = document.querySelector('x-resolve'); + const expected = 'relative/path.png'; + const actual = + el.resolveUrl('relative/path.png', '/not/a/full/uri'); + assert.equal(actual, expected); + }); + + test('resolveUrl when called with a full url and a bad baseURI', function () { + const el = document.querySelector('x-resolve'); + const expected = 'https://example.com/foo.png'; + const actual = + el.resolveUrl('https://example.com/foo.png', '/not/a/full/uri'); + assert.equal(actual, expected); + }); + + test('resolveUrl when called with a protocol-relative url and a bad baseURI', function () { + const el = document.querySelector('x-resolve'); + const expected = '//example.com/foo.png'; + const actual = + el.resolveUrl('//example.com/foo.png', '/not/a/full/uri'); + assert.equal(actual, expected); + }); + + test('resolveUrl when called with a garbage url', function () { + const el = document.querySelector('x-resolve'); + const expected = '.../foo.png'; + const actual = + el.resolveUrl('.../foo.png', 'https://example.org/bar'); + assert.equal(actual, expected); + }); + test('resolveUrl api with assetpath', function() { var el = document.createElement('p-r-ap'); // Manually calculate expected URL, to avoid dependence on