mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-24 06:59:52 +01:00
Merge pull request #159 from robertknight/anchor-override-tostring
wombat: Override HTMLAnchorElement.prototype.toString()
This commit is contained in:
commit
3e3d7e4d87
@ -34,7 +34,6 @@ function runWombatTest(testCase, done) {
|
|||||||
window.assert = {
|
window.assert = {
|
||||||
equal: function (a, b) {
|
equal: function (a, b) {
|
||||||
if (a !== b) {
|
if (a !== b) {
|
||||||
x.equal(a, b);
|
|
||||||
console.error('Mismatch between', a, 'and', b);
|
console.error('Mismatch between', a, 'and', b);
|
||||||
throw new Error('AssertionError');
|
throw new Error('AssertionError');
|
||||||
}
|
}
|
||||||
@ -133,8 +132,9 @@ describe('WombatJS', function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('anchor rewriting', function () {
|
describe('anchor rewriting', function () {
|
||||||
it('should rewrite links in dynamically injected <a> tags', function (done) {
|
var config;
|
||||||
runWombatTest({
|
beforeEach(function () {
|
||||||
|
config = {
|
||||||
initScript: function () {
|
initScript: function () {
|
||||||
wbinfo = {
|
wbinfo = {
|
||||||
wombat_opts: {},
|
wombat_opts: {},
|
||||||
@ -144,13 +144,28 @@ describe('WombatJS', function () {
|
|||||||
},
|
},
|
||||||
wombatScript: wombatScript,
|
wombatScript: wombatScript,
|
||||||
html: '<a href="foobar.html" id="link">A link</a>',
|
html: '<a href="foobar.html" id="link">A link</a>',
|
||||||
testScript: function () {
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should rewrite links in dynamically injected <a> tags', function (done) {
|
||||||
|
config.testScript = function () {
|
||||||
|
if (domTests.areDOMPropertiesConfigurable()) {
|
||||||
var link = document.getElementById('link');
|
var link = document.getElementById('link');
|
||||||
if (domTests.areDOMPropertiesConfigurable()) {
|
assert.equal(link.href, 'http:///base/karma-tests/foobar.html');
|
||||||
assert.equal(link.href, 'http:///base/karma-tests/foobar.html');
|
}
|
||||||
}
|
};
|
||||||
},
|
|
||||||
}, done);
|
runWombatTest(config, done);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('toString() should return the rewritten URL', function (done) {
|
||||||
|
config.testScript = function () {
|
||||||
|
if (domTests.areDOMPropertiesConfigurable()) {
|
||||||
|
var link = document.getElementById('link');
|
||||||
|
assert.equal(link.href, link.toString());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
runWombatTest(config, done);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1397,6 +1397,9 @@ var wombat_internal = function($wbwindow) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
init_loc_override($wbwindow.HTMLAnchorElement.prototype, anchor_setter, anchor_getter);
|
init_loc_override($wbwindow.HTMLAnchorElement.prototype, anchor_setter, anchor_getter);
|
||||||
|
$wbwindow.HTMLAnchorElement.prototype.toString = function () {
|
||||||
|
return this.href;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user