From d8232bb4843cb19770a6d2ecd574b7b9b98df2f3 Mon Sep 17 00:00:00 2001 From: Bart van den Eijnden Date: Fri, 24 May 2013 10:53:29 +0200 Subject: [PATCH 1/2] Fix XML serialize and xml_eql in IE9 Use the xml property instead in IE for serializing XML. The xml_eql tests were failing in IE9 on a difference between null and an empty string for namespaceURI of attributes, this difference is not relevant to our testing so make sure we ignore. --- src/ol/parser/xml.js | 4 +++- test/expect-0.2.0-ol3/expect.js | 13 ++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/ol/parser/xml.js b/src/ol/parser/xml.js index f158ca8614..e5c35f3d5c 100644 --- a/src/ol/parser/xml.js +++ b/src/ol/parser/xml.js @@ -256,7 +256,9 @@ ol.parser.XML.prototype.setAttributeNS = function(node, uri, name, value) { * @return {string} The serialized XML string. */ ol.parser.XML.prototype.serialize = function(node) { - if (node.nodeType == 1) { + if (this.xmldom) { + return node.xml; + } else if (node.nodeType == 1) { // Add nodes to a document before serializing. Everything else // is serialized as is. This is also needed to get all namespaces // defined in some browsers such as Chrome (xmlns attributes). diff --git a/test/expect-0.2.0-ol3/expect.js b/test/expect-0.2.0-ol3/expect.js index 987e8b6b8b..e1a8443090 100644 --- a/test/expect-0.2.0-ol3/expect.js +++ b/test/expect-0.2.0-ol3/expect.js @@ -318,7 +318,18 @@ } // test attribute namespace try { - expect(node1Attr[name].namespaceURI).to.equal(node2Attr[name].namespaceURI); + var uri1 = node1Attr[name].namespaceURI; + var uri2 = node2Attr[name].namespaceURI; + // we do not care about the difference between an empty string and null for namespaceURI + // some tests will fail in IE9 otherwise + // see also http://msdn.microsoft.com/en-us/library/ff460650(v=vs.85).aspx + if (uri1 == '') { + uri1 = null; + } + if (uri2 == '') { + uri2 = null; + } + expect(uri1).to.equal(uri2); } catch(e) { errors.push('namespaceURI attribute test failed for: ' + node1.nodeName + ' | ' + e.message); } From 0f3c1510582b1aa0d987d2aae8d8b054a13cb936 Mon Sep 17 00:00:00 2001 From: Bart van den Eijnden Date: Mon, 27 May 2013 11:04:27 +0200 Subject: [PATCH 2/2] implement review comment by @ahocevar --- test/expect-0.2.0-ol3/expect.js | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/test/expect-0.2.0-ol3/expect.js b/test/expect-0.2.0-ol3/expect.js index e1a8443090..052f9a1df2 100644 --- a/test/expect-0.2.0-ol3/expect.js +++ b/test/expect-0.2.0-ol3/expect.js @@ -318,18 +318,10 @@ } // test attribute namespace try { - var uri1 = node1Attr[name].namespaceURI; - var uri2 = node2Attr[name].namespaceURI; // we do not care about the difference between an empty string and null for namespaceURI // some tests will fail in IE9 otherwise // see also http://msdn.microsoft.com/en-us/library/ff460650(v=vs.85).aspx - if (uri1 == '') { - uri1 = null; - } - if (uri2 == '') { - uri2 = null; - } - expect(uri1).to.equal(uri2); + expect(node1Attr[name].namespaceURI || null).to.be(node2Attr[name].namespaceURI || null); } catch(e) { errors.push('namespaceURI attribute test failed for: ' + node1.nodeName + ' | ' + e.message); }