browser/components/feeds/test/test_bug436801.html

Thu, 15 Jan 2015 15:55:04 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:55:04 +0100
branch
TOR_BUG_9701
changeset 9
a63d609f5ebe
permissions
-rw-r--r--

Back out 97036ab72558 which inappropriately compared turds to third parties.

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <!--
michael@0 4 https://bugzilla.mozilla.org/show_bug.cgi?id=436801
michael@0 5 -->
michael@0 6 <head>
michael@0 7 <title>Test feed preview subscribe UI</title>
michael@0 8 <script type="text/javascript" src="/MochiKit/packed.js"></script>
michael@0 9 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 10 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
michael@0 11 </head>
michael@0 12 <body>
michael@0 13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=436801">Mozilla Bug 436801</a>
michael@0 14 <p id="display"><iframe id="testFrame" src="bug436801-data.xml"></iframe></p>
michael@0 15 <div id="content" style="display: none">
michael@0 16 </div>
michael@0 17 <pre id="test">
michael@0 18 <script class="testbody" type="text/javascript">
michael@0 19
michael@0 20 SimpleTest.waitForExplicitFinish();
michael@0 21
michael@0 22 addLoadEvent(function () {
michael@0 23 var doc = SpecialPowers.wrap($("testFrame")).contentDocument;
michael@0 24
michael@0 25 checkNode(doc.getElementById("feedTitleText"), [
michael@0 26 "ELEMENT", "h1", { "xml:base": "http://www.example.com/foo/bar/" }, [
michael@0 27 ["TEXT", "Example of a "],
michael@0 28 ["ELEMENT", "em", [
michael@0 29 ["TEXT", "special"],
michael@0 30 ]],
michael@0 31 ["TEXT", " feed ("],
michael@0 32 ["ELEMENT", "img", { "src": "baz.png" }],
michael@0 33 ["TEXT", ")"],
michael@0 34 ]
michael@0 35 ]);
michael@0 36
michael@0 37 checkNode(doc.getElementById("feedSubtitleText"), [
michael@0 38 "ELEMENT", "h2", { "xml:base": "http://www.example.com/foo/bar/" }, [
michael@0 39 ["TEXT", "With a "],
michael@0 40 ["ELEMENT", "em", [
michael@0 41 ["TEXT", "special"],
michael@0 42 ]],
michael@0 43 ["TEXT", " subtitle ("],
michael@0 44 ["ELEMENT", "img", { "src": "baz.png" }],
michael@0 45 ["TEXT", ")"],
michael@0 46 ]
michael@0 47 ]);
michael@0 48
michael@0 49 checkNode(doc.querySelector(".entry").firstChild.firstChild.firstChild, [
michael@0 50 "ELEMENT", "span", { "xml:base": "http://www.example.com/foo/bar/" }, [
michael@0 51 ["TEXT", "Some "],
michael@0 52 ["ELEMENT", "abbr", { title: "Extensible Hyper-text Mark-up Language" }, [
michael@0 53 ["TEXT", "XHTML"],
michael@0 54 ]],
michael@0 55 ["TEXT", " examples ("],
michael@0 56 ["ELEMENT", "img", { "src": "baz.png" }],
michael@0 57 ["TEXT", ")"],
michael@0 58 ]
michael@0 59 ]);
michael@0 60
michael@0 61 checkNode(doc.querySelectorAll(".entry")[1].firstChild.firstChild.firstChild, [
michael@0 62 "ELEMENT", "span", { "xml:base": "http://www.example.com/foo/bar/" }, [
michael@0 63 ["TEXT", "Some "],
michael@0 64 ["ELEMENT", "abbr", { title: "Hyper-text Mark-up Language" }, [
michael@0 65 ["TEXT", "HTML"],
michael@0 66 ]],
michael@0 67 ["TEXT", " examples ("],
michael@0 68 ["ELEMENT", "img", { "src": "baz.png" }],
michael@0 69 ["TEXT", ")"],
michael@0 70 ]
michael@0 71 ]);
michael@0 72 });
michael@0 73
michael@0 74 addLoadEvent(SimpleTest.finish);
michael@0 75
michael@0 76 function checkNode(node, schema) {
michael@0 77 var typeName = schema.shift() + "_NODE";
michael@0 78 var type = Node[typeName];
michael@0 79 is(node.nodeType, type, "Node should be expected type " + typeName);
michael@0 80 if (type == Node.TEXT_NODE) {
michael@0 81 var text = schema.shift();
michael@0 82 is(node.data, text, "Text should match");
michael@0 83 return;
michael@0 84 }
michael@0 85 // type == Node.ELEMENT_NODE
michael@0 86 var tag = schema.shift();
michael@0 87 is(node.localName, tag, "Element should have expected tag");
michael@0 88 while (schema.length) {
michael@0 89 var val = schema.shift();
michael@0 90 if (Array.isArray(val))
michael@0 91 var childSchema = val;
michael@0 92 else
michael@0 93 var attrSchema = val;
michael@0 94 }
michael@0 95 if (attrSchema) {
michael@0 96 var nsTable = {
michael@0 97 xml: "http://www.w3.org/XML/1998/namespace",
michael@0 98 };
michael@0 99 for (var name in attrSchema) {
michael@0 100 var [ns, nsName] = name.split(":");
michael@0 101 var val = nsName ? node.getAttributeNS(nsTable[ns], nsName) :
michael@0 102 node.getAttribute(name);
michael@0 103 is(val, attrSchema[name], "Attribute " + name + " should match");
michael@0 104 }
michael@0 105 }
michael@0 106 if (childSchema) {
michael@0 107 var numChildren = node.childNodes.length;
michael@0 108 is(childSchema.length, numChildren,
michael@0 109 "Element should have expected number of children");
michael@0 110 for (var i = 0; i < numChildren; i++)
michael@0 111 checkNode(node.childNodes[i], childSchema[i]);
michael@0 112 }
michael@0 113 }
michael@0 114
michael@0 115 </script>
michael@0 116 </pre>
michael@0 117 </body>
michael@0 118 </html>

mercurial