From 9c88b1fd209b7d7d19c14cff7df6cf1b8aa08c53 Mon Sep 17 00:00:00 2001 From: Robert Knight Date: Thu, 26 Nov 2015 10:15:35 +0000 Subject: [PATCH] Enable running Karma tests against Safari Detect in the test whether overriding of DOM properties is supported in the current environment and skip testing for the baseURI override in that case. --- karma-tests/wombat.spec.js | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/karma-tests/wombat.spec.js b/karma-tests/wombat.spec.js index 7012da83..8bebb8de 100644 --- a/karma-tests/wombat.spec.js +++ b/karma-tests/wombat.spec.js @@ -44,8 +44,21 @@ function runWombatTest(testCase, done) { }; // expose chai's assertion testing API to the test script - assert = window.parent.assert; - reportError = window.parent.reportError; + window.assert = window.parent.assert; + window.reportError = window.parent.reportError; + + // helpers which check whether DOM property overrides are supported + // in the current browser + window.domTests = { + areDOMPropertiesConfigurable: function () { + var descriptor = Object.getOwnPropertyDescriptor(Node.prototype, 'baseURI'); + if (descriptor && !descriptor.configurable) { + return false; + } else { + return true; + } + } + }; }); try { @@ -123,7 +136,9 @@ describe('WombatJS', function () { if (typeof baseURI !== 'string') { throw new Error('baseURI is not a string'); } - assert.equal(baseURI, 'http:///dummy.html'); + if (domTests.areDOMPropertiesConfigurable()) { + assert.equal(baseURI, 'http:///dummy.html'); + } }, }, done); }); @@ -141,7 +156,9 @@ describe('WombatJS', function () { html: 'A link', testScript: function () { var link = document.getElementById('link'); - assert.equal(link.href, 'http:///foobar.html'); + if (domTests.areDOMPropertiesConfigurable()) { + assert.equal(link.href, 'http:///foobar.html'); + } }, }, done); });