1 | var isQuirks = document.compatMode == "BackCompat"; |
---|
2 | |
---|
3 | function runScrollingTest(resultNode){ |
---|
4 | // reposition the absolute-positioned tag to the top/left of the static control |
---|
5 | // element and check to make sure each has the same offsetLeft/Top |
---|
6 | if(!("dojo" in window)){ |
---|
7 | var doc = frameElement.ownerDocument; |
---|
8 | var win = doc.parentWindow || doc.defaultView; |
---|
9 | dojo = win.dojo; |
---|
10 | } |
---|
11 | var isLtr = dojo.hitch(dojo, "withGlobal")(window, "_isBodyLtr", dojo, []); |
---|
12 | var root = isQuirks? document.body : document.documentElement; |
---|
13 | var control = document.getElementById("control"); |
---|
14 | var clientWidth = document.getElementById("clientWidth"); |
---|
15 | var abs1 = document.getElementById("abs1"); |
---|
16 | window.scrollTo(0, 0); // start with standarized placement |
---|
17 | setTimeout(function(){ |
---|
18 | var cw = dojo.hitch(dojo, "withGlobal")(window, "position", dojo, [clientWidth, false]); |
---|
19 | if(cw.x != 0){ |
---|
20 | scrollBy(cw.x, 0); // scroll width:100% control element fully into view |
---|
21 | } |
---|
22 | var p = dojo.hitch(dojo, "withGlobal")(window, "position", dojo, [control, true]); |
---|
23 | abs1.style.left = p.x + "px"; |
---|
24 | abs1.style.top = p.y + "px"; |
---|
25 | setTimeout(function(){ |
---|
26 | cw = dojo.hitch(dojo, "withGlobal")(window, "position", dojo, [clientWidth, false]); |
---|
27 | if(cw.x >= 0 || (cw.x < 0 && Math.round(root.clientWidth - cw.w - cw.x) == 0)){ |
---|
28 | if(abs1.offsetLeft == control.offsetLeft){ |
---|
29 | if(abs1.offsetTop == control.offsetTop){ |
---|
30 | resultNode.testResult = "EQUAL"; |
---|
31 | }else{ |
---|
32 | resultNode.testResult = "abs1.offsetTop="+abs1.offsetTop + " control.offsetTop="+control.offsetTop; |
---|
33 | } |
---|
34 | }else{ |
---|
35 | resultNode.testResult = "abs1.offsetLeft="+abs1.offsetLeft + " control.offsetLeft="+control.offsetLeft; |
---|
36 | } |
---|
37 | }else{ |
---|
38 | resultNode.testResult = "100% width element start/size=" + cw.x+'/'+cw.w + " frame client left/width="+root.clientLeft+'/'+root.clientWidth; |
---|
39 | } |
---|
40 | if(resultNode.resultReady){ resultNode.resultReady(); } |
---|
41 | }, 100); |
---|
42 | }, 100); |
---|
43 | } |
---|
44 | |
---|
45 | function genScrollingTestNodes(hScroll, vScroll, large){ |
---|
46 | document.write( |
---|
47 | '<DIV id="abs1" style="position:absolute;background-color:red;left:0;top:0;width:1em;font-family:monospace;font-size:16px;"> </DIV>' + |
---|
48 | '<DIV id="control" style="width:2em;height:2em;font-family:monospace;font-size:16px;background-color:cyan;margin:0 1em;border:0;padding:0;"> </DIV>' + |
---|
49 | ( large |
---|
50 | ? ( |
---|
51 | (hScroll ? '<DIV style="float:left;position:relative;width:600px;"> </DIV>' : '') + |
---|
52 | (hScroll ? '<DIV style="float:right;position:relative;width:600px;"> </DIV>' : '') + |
---|
53 | (vScroll ? '<CENTER style="width:1px;height:600px;"> </CENTER>' : '') |
---|
54 | ) |
---|
55 | : '' |
---|
56 | ) + |
---|
57 | ''); |
---|
58 | } |
---|
59 | |
---|
60 | function genScrollingTestBody(){ |
---|
61 | var options = window.location.search.substr(1).toLowerCase().split(/&/); |
---|
62 | options.dir = "ltr"; |
---|
63 | for(var i=0; i < options.length; i++){ |
---|
64 | var option = options[i]; |
---|
65 | switch(option){ |
---|
66 | case "ltr": |
---|
67 | case "rtl": |
---|
68 | options.dir = option; |
---|
69 | break; |
---|
70 | case"both": |
---|
71 | options.horz = 1; |
---|
72 | options.vert = 1; |
---|
73 | break; |
---|
74 | default: options[option] = 1; |
---|
75 | } |
---|
76 | } |
---|
77 | var html = document.getElementsByTagName("HTML")[0]; |
---|
78 | html.dir = options.dir; |
---|
79 | // the setTimeout in the onload allows the browser time to scroll the iframe to the previous position |
---|
80 | var scroll = options.large ? '' : 'scroll'; |
---|
81 | if(!options.horz){ |
---|
82 | html.style.overflowX = "hidden"; |
---|
83 | }else if(!isQuirks && !options.large){ |
---|
84 | html.style.overflowX = scroll; |
---|
85 | } |
---|
86 | if(!options.vert){ |
---|
87 | html.style.overflowY = "hidden"; |
---|
88 | }else if(!isQuirks && !options.large){ |
---|
89 | html.style.overflowY = scroll; |
---|
90 | } |
---|
91 | document.write('<BODY style="height:100%;margin:0;padding:0;border:0;background-color:white;overflow-x:' + (options.horz ? (isQuirks ? scroll : '') : 'hidden') + ';overflow-y:' + (isQuirks ? (options.vert ? scroll : 'hidden') : '') + ';">'); |
---|
92 | document.write('<DIV id="clientWidth"><CENTER>'+(isQuirks?'quirks ':'strict ')+(options.horz?'horiz ':'')+(options.vert?'vert ':'')+(options.large?'scrolling ':'')+options.dir+'</CENTER></DIV>'); |
---|
93 | genScrollingTestNodes(options.horz, options.vert, options.large); |
---|
94 | document.write('</BODY>'); |
---|
95 | } |
---|
96 | |
---|
97 | if(!document.body){ |
---|
98 | frameElement.runScrollingTest = runScrollingTest; |
---|
99 | genScrollingTestBody(); |
---|
100 | }else{ |
---|
101 | document.write('<DIV id="clientWidth" style="background-color:transparent;"> </DIV>'); |
---|
102 | genScrollingTestNodes(); |
---|
103 | } |
---|