Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | <!DOCTYPE HTML> |
michael@0 | 2 | <html> |
michael@0 | 3 | <head> |
michael@0 | 4 | <title>Test for mapping of scrollTop/scrollLeft to viewport</title> |
michael@0 | 5 | <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
michael@0 | 6 | <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> |
michael@0 | 7 | </head> |
michael@0 | 8 | <body onload="doTest()"> |
michael@0 | 9 | <p id="display"></p> |
michael@0 | 10 | |
michael@0 | 11 | <iframe id="quirks"></iframe> |
michael@0 | 12 | <iframe id="standards"></iframe> |
michael@0 | 13 | <iframe id="xml"></iframe> |
michael@0 | 14 | |
michael@0 | 15 | <pre id="test"> |
michael@0 | 16 | <script type="application/javascript"> |
michael@0 | 17 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 18 | |
michael@0 | 19 | var quirks = document.getElementById("quirks"); |
michael@0 | 20 | var standards = document.getElementById("standards"); |
michael@0 | 21 | var xml = document.getElementById("xml"); |
michael@0 | 22 | |
michael@0 | 23 | quirks.src = "data:text/html,<html><body style='height:2000px; width:2000px;'>"; |
michael@0 | 24 | standards.src = "data:text/html,<!DOCTYPE HTML><html><body style='height:2000px; width:2000px;'>"; |
michael@0 | 25 | xml.src = "data:text/xml,<?xml-stylesheet href='data:text/css,html { display:block; height:2000px; width:2000px; }'?><foo><html></html></foo>"; |
michael@0 | 26 | |
michael@0 | 27 | function subtest(winProp, elemProp, win, correctElement, elemToSet, otherElem1, otherElem2) { |
michael@0 | 28 | win.scrollTo(50, 50); |
michael@0 | 29 | elemToSet[elemProp] = 100; |
michael@0 | 30 | if (elemToSet == correctElement) { |
michael@0 | 31 | is(win[winProp], 100, "Setting " + elemToSet.name + "." + elemProp + " should scroll"); |
michael@0 | 32 | is(elemToSet[elemProp], 100, "Reading back " + elemToSet.name + "." + elemProp + " after scrolling"); |
michael@0 | 33 | } else { |
michael@0 | 34 | is(win[winProp], 50, "Setting " + elemToSet.name + "." + elemProp + " should not scroll"); |
michael@0 | 35 | is(elemToSet[elemProp], 0, "Reading back " + elemToSet.name + "." + elemProp + " after not scrolling"); |
michael@0 | 36 | } |
michael@0 | 37 | if (otherElem1 == correctElement) { |
michael@0 | 38 | is(otherElem1[elemProp], 50, "Reading back " + otherElem1.name + "." + elemProp + " (correct element) after not scrolling"); |
michael@0 | 39 | } else { |
michael@0 | 40 | is(otherElem1[elemProp], 0, "Reading back " + otherElem1.name + "." + elemProp + " (irrelevant element)"); |
michael@0 | 41 | } |
michael@0 | 42 | if (otherElem2 == correctElement) { |
michael@0 | 43 | is(otherElem2[elemProp], 50, "Reading back " + otherElem2.name + "." + elemProp + " (correct element) after not scrolling"); |
michael@0 | 44 | } else { |
michael@0 | 45 | is(otherElem2[elemProp], 0, "Reading back " + otherElem2.name + "." + elemProp + " (irrelevant element)"); |
michael@0 | 46 | } |
michael@0 | 47 | } |
michael@0 | 48 | |
michael@0 | 49 | function testScroll(winProp, elemProp, win, elemToSet, otherElem1, otherElem2) { |
michael@0 | 50 | subtest(winProp, elemProp, win, elemToSet, elemToSet, otherElem1, otherElem2); |
michael@0 | 51 | subtest(winProp, elemProp, win, elemToSet, otherElem1, elemToSet, otherElem2); |
michael@0 | 52 | subtest(winProp, elemProp, win, elemToSet, otherElem2, elemToSet, otherElem1); |
michael@0 | 53 | } |
michael@0 | 54 | |
michael@0 | 55 | function doTest() { |
michael@0 | 56 | var quirksRoot = quirks.contentDocument.documentElement; |
michael@0 | 57 | quirksRoot.name = "quirks HTML"; |
michael@0 | 58 | var quirksBody = quirks.contentDocument.body; |
michael@0 | 59 | quirksBody.name = "quirks BODY"; |
michael@0 | 60 | var quirksBody2 = quirks.contentDocument.createElement("body"); |
michael@0 | 61 | quirksBody2.name = "quirks other BODY"; |
michael@0 | 62 | quirksRoot.appendChild(quirksBody2); |
michael@0 | 63 | testScroll("scrollX", "scrollLeft", quirks.contentWindow, quirksBody, quirksRoot, quirksBody2); |
michael@0 | 64 | testScroll("scrollY", "scrollTop", quirks.contentWindow, quirksBody, quirksRoot, quirksBody2); |
michael@0 | 65 | |
michael@0 | 66 | var standardsRoot = standards.contentDocument.documentElement; |
michael@0 | 67 | standardsRoot.name = "standards HTML"; |
michael@0 | 68 | var standardsBody = standards.contentDocument.body; |
michael@0 | 69 | standardsBody.name = "standards BODY"; |
michael@0 | 70 | var standardsBody2 = standards.contentDocument.createElement("body"); |
michael@0 | 71 | standardsBody2.name = "standards other BODY"; |
michael@0 | 72 | standardsRoot.appendChild(standardsBody2); |
michael@0 | 73 | testScroll("scrollX", "scrollLeft", standards.contentWindow, standardsRoot, standardsBody, standardsBody2); |
michael@0 | 74 | testScroll("scrollY", "scrollTop", standards.contentWindow, standardsRoot, standardsBody, standardsBody2); |
michael@0 | 75 | |
michael@0 | 76 | var xmlRoot = xml.contentDocument.documentElement; |
michael@0 | 77 | xmlRoot.name = "XML root"; |
michael@0 | 78 | var xmlOther = xmlRoot.firstChild; |
michael@0 | 79 | xmlOther.name = "XML other"; |
michael@0 | 80 | testScroll("scrollX", "scrollLeft", xml.contentWindow, xmlRoot, xmlOther, xmlOther); |
michael@0 | 81 | testScroll("scrollY", "scrollTop", xml.contentWindow, xmlRoot, xmlOther, xmlOther); |
michael@0 | 82 | |
michael@0 | 83 | SimpleTest.finish(); |
michael@0 | 84 | } |
michael@0 | 85 | </script> |
michael@0 | 86 | |
michael@0 | 87 | </pre> |
michael@0 | 88 | </body> |
michael@0 | 89 | </html> |