diff options
author | Matt A. Tobin <email@mattatobin.com> | 2020-02-25 15:07:00 -0500 |
---|---|---|
committer | Matt A. Tobin <email@mattatobin.com> | 2020-02-25 15:07:00 -0500 |
commit | 0ddd00f1959c78ce37c14fef3c83401408fca3bf (patch) | |
tree | d408e02767c86cf8aac3acbb86722b03c77ede6f /toolkit/components/microformats/test/lib/domparser.js | |
parent | 20f0905b33cbb18d1caa80c55e2f552c2e18957b (diff) | |
download | UXP-0ddd00f1959c78ce37c14fef3c83401408fca3bf.tar UXP-0ddd00f1959c78ce37c14fef3c83401408fca3bf.tar.gz UXP-0ddd00f1959c78ce37c14fef3c83401408fca3bf.tar.lz UXP-0ddd00f1959c78ce37c14fef3c83401408fca3bf.tar.xz UXP-0ddd00f1959c78ce37c14fef3c83401408fca3bf.zip |
Issue #439 - Remove tests from toolkit/
Diffstat (limited to 'toolkit/components/microformats/test/lib/domparser.js')
-rw-r--r-- | toolkit/components/microformats/test/lib/domparser.js | 103 |
1 files changed, 0 insertions, 103 deletions
diff --git a/toolkit/components/microformats/test/lib/domparser.js b/toolkit/components/microformats/test/lib/domparser.js deleted file mode 100644 index bc342634a..000000000 --- a/toolkit/components/microformats/test/lib/domparser.js +++ /dev/null @@ -1,103 +0,0 @@ - -// Based on https://gist.github.com/1129031 By Eli Grey, http://eligrey.com - Public domain. - -// DO NOT use https://developer.mozilla.org/en-US/docs/Web/API/DOMParser example polyfill -// as it does not work with earlier versions of Chrome - - -(function(DOMParser) { - 'use strict'; - - var DOMParser_proto; - var real_parseFromString; - var textHTML; // Flag for text/html support - var textXML; // Flag for text/xml support - var htmlElInnerHTML; // Flag for support for setting html element's innerHTML - - // Stop here if DOMParser not defined - if (!DOMParser) { - return; - } - - // Firefox, Opera and IE throw errors on unsupported types - try { - // WebKit returns null on unsupported types - textHTML = !!(new DOMParser()).parseFromString('', 'text/html'); - - } catch (er) { - textHTML = false; - } - - // If text/html supported, don't need to do anything. - if (textHTML) { - return; - } - - // Next try setting innerHTML of a created document - // IE 9 and lower will throw an error (can't set innerHTML of its HTML element) - try { - var doc = document.implementation.createHTMLDocument(''); - doc.documentElement.innerHTML = '<title></title><div></div>'; - htmlElInnerHTML = true; - - } catch (er) { - htmlElInnerHTML = false; - } - - // If if that failed, try text/xml - if (!htmlElInnerHTML) { - - try { - textXML = !!(new DOMParser()).parseFromString('', 'text/xml'); - - } catch (er) { - textHTML = false; - } - } - - // Mess with DOMParser.prototype (less than optimal...) if one of the above worked - // Assume can write to the prototype, if not, make this a stand alone function - if (DOMParser.prototype && (htmlElInnerHTML || textXML)) { - DOMParser_proto = DOMParser.prototype; - real_parseFromString = DOMParser_proto.parseFromString; - - DOMParser_proto.parseFromString = function (markup, type) { - - // Only do this if type is text/html - if (/^\s*text\/html\s*(?:;|$)/i.test(type)) { - var doc, doc_el, first_el; - - // Use innerHTML if supported - if (htmlElInnerHTML) { - doc = document.implementation.createHTMLDocument(''); - doc_el = doc.documentElement; - doc_el.innerHTML = markup; - first_el = doc_el.firstElementChild; - - // Otherwise use XML method - } else if (textXML) { - - // Make sure markup is wrapped in HTML tags - // Should probably allow for a DOCTYPE - if (!(/^<html.*html>$/i.test(markup))) { - markup = '<html>' + markup + '<\/html>'; - } - doc = (new DOMParser()).parseFromString(markup, 'text/xml'); - doc_el = doc.documentElement; - first_el = doc_el.firstElementChild; - } - - // Is this an entire document or a fragment? - if (doc_el.childElementCount === 1 && first_el.localName.toLowerCase() === 'html') { - doc.replaceChild(first_el, doc_el); - } - - return doc; - - // If not text/html, send as-is to host method - } else { - return real_parseFromString.apply(this, arguments); - } - }; - } -}(DOMParser)); |