source: Dev/trunk/src/client/dojo/tests/_base/html_rtl.html

Last change on this file was 483, checked in by hendrikvanantwerpen, 11 years ago

Added Dojo 1.9.3 release.

File size: 5.2 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2        "http://www.w3.org/TR/html4/strict.dtd">
3<html dir="rtl">
4        <head>
5                <title>testing Core HTML/DOM/CSS/Style utils</title>
6                <style type="text/css">
7                        @import "../../resources/dojo.css";
8                </style>
9                <script type="text/javascript" src="../../dojo.js" data-dojo-config="isDebug:true"></script>
10                <script type="text/javascript">
11                        require(["dojo", "doh", "dojo/domReady!"], function(dojo, doh){
12                       
13                                doh.register("rtl",
14                                        [
15                                                {
16                                                        name: "coordsWithScrolling",
17                                                        timeout: 1000,
18                                                        runTest: function(t){
19                                                                var d = new doh.Deferred();
20                                                                setTimeout(d.getTestErrback(function(){ // allow browsers time to return the scroll point back to the last position
21                                                                        scrollTo(100, 100); // scroll a little
22                                                                        scrollBy(-50, -50); // net 50px horizontal movement: back-n-forth scrolling helps with different browsers
23                                                                        setTimeout(d.getTestCallback(function(){ // time to scroll
24                                                                                var pos = dojo.position('rect100', true);
25                                                                                t.is(100, pos.y, "y pos should be 100 after vertical scroll");
26                                                                                t.is(100, pos.x, "x pos should be 100 after horizontal scroll");
27                                                                        }), 100);
28                                                                }), 100);
29                                                                return d;
30                                                        }
31                                                },
32
33                                                {
34                                                        name: "eventClientXY_IE",
35                                                        timeout: 2000,
36                                                        runTest: function(t){
37                                                                var
38                                                                d = new doh.Deferred(),
39                                                                rect = dojo.byId("rect100"),
40                                                                handler = dojo.connect(rect.offsetParent, "onclick", null,
41                                                                        d.getTestErrback(function(e){
42                                                                                // move the rectangle to the mouse point
43                                                                                dojo.disconnect(handler);
44                                                                                var     scroll = dojo.docScroll(),
45                                                                                        pageX = (e.pageX || e.pageY) ? e.pageX : ((e.clientX || 0) + scroll.x),
46                                                                                        pageY = (e.pageX || e.pageY) ? e.pageY : ((e.clientY || 0) + scroll.y);
47                                                                                rect.style.left = pageX + "px";
48                                                                                rect.style.top = pageY + "px";
49                                                                                setTimeout(d.getTestCallback(function(){
50                                                                                        var rectPos = dojo.position(rect, true);
51                                                                                        t.is(pageX, rectPos.x, "pageX");
52                                                                                        t.is(pageY, rectPos.y, "pageY");
53                                                                                }), 500); // time to move rect to cursor position
54                                                                        })
55                                                                );
56                                                                rect.scrollIntoView();
57                                                                setTimeout(d.getTestErrback(function(){
58                                                                        if(!("dispatchEvent" in rect.offsetParent)){
59                                                                                rect.offsetParent.fireEvent('onclick'); // IE < 9
60                                                                        }else{
61                                                                                var clickEvent = rect.offsetParent.ownerDocument.createEvent("MouseEvent");
62                                                                                clickEvent.initMouseEvent("click", false, false, window, 0,0,0,60,60,0,0,0,0,0,null);
63                                                                                rect.offsetParent.dispatchEvent(clickEvent);
64                                                                        }
65                                                                }), 500); // time to finish any pre-scrolling
66                                                                return d;
67                                                        }
68                                                },
69
70                                                {
71                                                        name: "testScrolledPosition",
72                                                        timeout: 10000,
73                                                        runTest: function(t){
74                                                                var d = new doh.Deferred(),
75                                                                        control = dojo.doc.getElementById('control');
76                                                                control.resultReady = d.getTestCallback(function(){
77                                                                        t.is("EQUAL", control.testResult);
78                                                                });
79                                                                runScrollingTest(control);
80                                                                return d;
81                                                        }
82                                                }
83                                        ]
84                                );
85
86                                // test to make sure position() works with a variety of scrollbars
87                                dojo.forEach(["None", "Horz", "Vert", "Both"], function(scroll){
88                                        dojo.forEach(["Quirks", "Strict"], function(doctype){
89                                                dojo.forEach(["Small", "Large"], function(size){
90                                                        var id = "scrolling" + doctype + "Iframe" + scroll + size;
91                                                        doh.register(id, {
92                                                                name: "test_" + id,
93                                                                timeout: 4000,
94                                                                runTest: function(t){
95                                                                        var d = new doh.Deferred(),
96                                                                                s = document.createElement('SPAN');
97                                                                        s.loaded = function(iframe){
98                                                                                // resultReady is called from inside the iframe
99                                                                                iframe.resultReady = d.getTestCallback(function(){
100                                                                                        t.is('EQUAL', iframe.testResult);
101                                                                                });
102                                                                                iframe.runScrollingTest(iframe);
103                                                                        };
104                                                                        s.innerHTML = '<iframe class="iframeTest" id="' + id + '" src="scrolling' + doctype + 'Iframe.html?rtl&' + scroll + '&' + size +'" frameborder="0" onload="this.parentNode.loaded(this)" style="background-color:gray;" allowtransparency></iframe>';
105                                                                        dojo.byId("iframeContainer").appendChild(s);
106                                                                        return d;
107                                                                }
108                                                        });
109                                                });
110                                        });
111                                });
112
113                                doh.runOnLoad();
114                        });
115                </script>
116                <style type="text/css">
117                        #rect100 {
118                                background-color: black;
119                                color: white;
120                                position: absolute;
121                                left: 100px;
122                                top: 100px;
123                                width: 100px;
124                                height: 100px;
125                                border: 0px;
126                                padding: 0px;
127                                margin: 0px;
128                                overflow: hidden;
129                        }
130
131                        .iframeTest {
132                                border: 5px solid black;
133                        }
134                </style>
135        </head>
136        <body style="min-height:2000px;min-width:2000px;">
137                <h1>testing Core HTML/DOM/CSS/Style utils</h1>
138                <div id="rect100">
139                        100px rect, abs,
140                        mouse point is at top-left after the test "eventClientXY"
141                </div>
142                <div id="rect_vert" style="padding:100px;visibility:hidden;"><input disabled value="show vertical scrollbar" style="display:block;height:100%;"></div>
143                <div id="rect_horz" style="padding:100px;visibility:hidden;"><input disabled value="show horizonal scrollbar" style="display:block;width:100%;"></div>
144                <br>
145                <script type="text/javascript" src="scrollingIframe.js"></script>
146                <div id="iframeContainer"></div>
147        </body>
148</html>
Note: See TracBrowser for help on using the repository browser.