This repository has been archived by the owner on Mar 13, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Skip absolute paths, since those are broken
- Loading branch information
Showing
2 changed files
with
66 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Copyright 2013 The Polymer Authors. All rights reserved. | ||
* Use of this source code is governed by a BSD-style | ||
* license that can be found in the LICENSE file. | ||
*/ | ||
|
||
suite('resolvePath', function() { | ||
var assert = chai.assert; | ||
|
||
var work = document.createElement('div'); | ||
var a = document.createElement('a'); | ||
var resolver, apResolver; | ||
|
||
function dirname(levels) { | ||
levels = levels || 1; | ||
var pp = location.href.split('/'); | ||
for (var i = 0; i < levels; i++) { | ||
pp.pop(); | ||
} | ||
return pp.join('/'); | ||
} | ||
|
||
// resolvePath may not remove '../', pass through an anchor to clean | ||
function urlResolve(resolver, path) { | ||
var junkyPath = resolver.resolvePath(path); | ||
a.href = junkyPath; | ||
// magical url voodoo | ||
return a.href; | ||
} | ||
|
||
suiteSetup(function() { | ||
wrap(document.body).appendChild(work); | ||
Polymer('x-resolve'); | ||
Polymer('x-resolve-ap'); | ||
work.innerHTML = '<polymer-element name="x-resolve"></polymer-element><polymer-element name="x-resolve-ap" assetpath="foo/bar/baz/"></polymer-element>'; | ||
CustomElements.takeRecords(); | ||
resolver = document.createElement('x-resolve'); | ||
apResolver = document.createElement('x-resolve-ap'); | ||
}); | ||
|
||
suiteTeardown(function() { | ||
wrap(document.body).removeChild(work); | ||
}); | ||
|
||
test('relative path', function() { | ||
assert.equal(urlResolve(resolver, 'foo.js'), dirname() + '/foo.js'); | ||
assert.equal(urlResolve(resolver, 'bar/baz'), dirname() + '/bar/baz'); | ||
assert.equal(urlResolve(resolver, '../test/foo'), dirname() + '/foo'); | ||
}); | ||
|
||
test.skip('absolute path', function() { | ||
assert.equal(resolver.resolvePath('http://example.com/bar'), 'http://example.com/bar'); | ||
}); | ||
|
||
test('assetpath relative path', function() { | ||
assert.equal(urlResolve(apResolver, 'foo.js'), dirname() + '/foo/bar/baz/foo.js'); | ||
assert.equal(urlResolve(apResolver, 'bar/baz'), dirname() + '/foo/bar/baz/bar/baz'); | ||
assert.equal(urlResolve(apResolver, '../test/foo'), dirname() + '/foo/bar/test/foo'); | ||
}); | ||
|
||
test.skip('assetpath absolute path', function() { | ||
assert.equal(urlResolve(apResolver, 'http://example.com/bar'), 'http://example.com/bar'); | ||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters