root / dojo / trunk / tests / _base / html.html

Revision 20576, 29.0 kB (checked in by doughays, 4 months ago)

Fixes #10095 !strict. Change destroy() to remember the current _destroyContainer ownerDocument to keep IE from throwing an exception when accessing the ownerDocument attribute later. Added automated testcase to html.html.

  • Property svn:eol-style set to native
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2        "http://www.w3.org/TR/html4/strict.dtd">
3<!--
4        we use a strict-mode DTD to ensure that the box model is the same for these
5        basic tests
6-->
7<html>
8        <head>
9                <title>testing Core HTML/DOM/CSS/Style utils</title>
10                <style type="text/css">
11                        @import "../../resources/dojo.css";
12                </style>
13                <script type="text/javascript"
14                        src="../../dojo.js"
15                        djConfig="isDebug: true"></script>
16                <script type="text/javascript">
17                        dojo.require("doh.runner");
18
19                        function getIframeDocument(/*DOMNode*/iframeNode){
20                                //summary: Returns the document object associated with the iframe DOM Node argument.
21                                var doc = iframeNode.contentDocument || // W3
22                                        (
23                                                (iframeNode.contentWindow)&&(iframeNode.contentWindow.document)
24                                        ) ||  // IE
25                                        (
26                                                (iframeNode.name)&&(document.frames[iframeNode.name])&&
27                                                (documendoh.frames[iframeNode.name].document)
28                                        ) || null;
29                                return doc;
30                        }
31
32
33                        dojo.addOnLoad(function(){
34                                // IE gets confused by the iframe when you press Refresh so load them dynamically
35                                var iframe_div = dojo.byId('iframe_div');
36                                dojo.addOnWindowUnload(function(){
37                                        iframe_div.innerHTML = 'unloading';
38                                });
39                                setTimeout(function(){
40                                        iframe_div.innerHTML = '<iframe src="absStrictIframe.html" name="iframe_strict" id="iframe_strict" \
41                                                style="border:3px solid black; padding:4px; margin:5px; background-color:black;" \
42                                                scrolling=yes allowtransparency=true></iframe>\
43                                        <iframe src="absQuirksIframe.html" name="iframe_quirks" id="iframe_quirks" \
44                                                style="border:3px solid black; padding:4px; margin:5px; background-color:black;" \
45                                                scrolling=yes allowtransparency=true></iframe>'; //'balanced
46                                }, 0);
47
48                                doh.register("t",
49                                        [
50                                                "doh.is(null, dojo.byId('nonExistantId'));",
51                                                "doh.is(null, dojo.byId(null));",
52                                                "doh.is(null, dojo.byId(''));",
53                                                "doh.is(undefined, dojo.byId(undefined));",
54
55                                                "doh.is(100, dojo.marginBox('sq100').w);",
56                                                "doh.is(100, dojo.marginBox('sq100').h);",
57
58                                                "doh.is(120, dojo.marginBox('sq100margin10').w);",
59                                                "doh.is(120, dojo.marginBox('sq100margin10').h);",
60                                                "doh.is(100, dojo.contentBox('sq100margin10').w);",
61                                                "doh.is(100, dojo.contentBox('sq100margin10').h);",
62
63                                                "doh.is(140, dojo.marginBox('sq100margin10pad10').w);",
64                                                "doh.is(140, dojo.marginBox('sq100margin10pad10').h);",
65
66                                                "doh.is(120, dojo.marginBox('sq100pad10').w);",
67                                                "doh.is(120, dojo.marginBox('sq100pad10').h);",
68
69                                                "doh.is(110, dojo.marginBox('sq100ltpad10').w);",
70                                                "doh.is(110, dojo.marginBox('sq100ltpad10').h);",
71                                                "doh.is(100, dojo.contentBox('sq100ltpad10').w);",
72                                                "doh.is(100, dojo.contentBox('sq100ltpad10').h);",
73
74                                                "doh.is(120, dojo.marginBox('sq100ltpad10rbmargin10').w);",
75                                                "doh.is(120, dojo.marginBox('sq100ltpad10rbmargin10').h);",
76
77                                                "doh.is(120, dojo.marginBox('sq100border10').w);",
78                                                "doh.is(120, dojo.marginBox('sq100border10').h);",
79                                                "doh.is(100, dojo.contentBox('sq100border10').w);",
80                                                "doh.is(100, dojo.contentBox('sq100border10').h);",
81
82                                                "doh.is(140, dojo.marginBox('sq100border10margin10').w);",
83                                                "doh.is(140, dojo.marginBox('sq100border10margin10').h);",
84                                                "doh.is(100, dojo.contentBox('sq100border10margin10').w);",
85                                                "doh.is(100, dojo.contentBox('sq100border10margin10').h);",
86
87                                                "doh.is(160, dojo.marginBox('sq100border10margin10pad10').w);",
88                                                "doh.is(160, dojo.marginBox('sq100border10margin10pad10').h);",
89                                                "doh.is(100, dojo.contentBox('sq100border10margin10pad10').w);",
90                                                "doh.is(100, dojo.contentBox('sq100border10margin10pad10').h);",
91
92                                                // FIXME: the 'correct' w is not 100 on Safari WebKit (2.0.4 [419.3]), the right-margin extends to the document edge
93                                                // "doh.is(100, dojo.marginBox('sq100nopos').w);",
94                                                "doh.is(100, dojo.marginBox('sq100nopos').h);",
95
96                                                "doh.is(10, dojo._getPadExtents(dojo.byId('sq100ltpad10rbmargin10')).l);",
97                                                "doh.is(10, dojo._getPadExtents(dojo.byId('sq100ltpad10rbmargin10')).t);",
98                                                "doh.is(10, dojo._getPadExtents(dojo.byId('sq100ltpad10rbmargin10')).w);",
99                                                "doh.is(10, dojo._getPadExtents(dojo.byId('sq100ltpad10rbmargin10')).h);",
100
101                                                "doh.is(0, dojo._getMarginExtents(dojo.byId('sq100ltpad10rbmargin10')).l);",
102                                                "doh.is(0, dojo._getMarginExtents(dojo.byId('sq100ltpad10rbmargin10')).t);",
103                                                "doh.is(10, dojo._getMarginExtents(dojo.byId('sq100ltpad10rbmargin10')).w);",
104                                                "doh.is(10, dojo._getMarginExtents(dojo.byId('sq100ltpad10rbmargin10')).h);",
105
106                                                "doh.is(10, dojo._getBorderExtents(dojo.byId('sq100border10margin10pad10')).l);",
107                                                "doh.is(10, dojo._getBorderExtents(dojo.byId('sq100border10margin10pad10')).t);",
108                                                "doh.is(20, dojo._getBorderExtents(dojo.byId('sq100border10margin10pad10')).w);",
109                                                "doh.is(20, dojo._getBorderExtents(dojo.byId('sq100border10margin10pad10')).h);",
110
111                                                "doh.is(20, dojo._getPadBorderExtents(dojo.byId('sq100border10margin10pad10')).l);",
112                                                "doh.is(20, dojo._getPadBorderExtents(dojo.byId('sq100border10margin10pad10')).t);",
113                                                "doh.is(40, dojo._getPadBorderExtents(dojo.byId('sq100border10margin10pad10')).w);",
114                                                "doh.is(40, dojo._getPadBorderExtents(dojo.byId('sq100border10margin10pad10')).h);",
115
116                                                function scrollUp(){
117                                                        dojo.doc.documentElement.scrollTop = 0;
118                                                },
119
120                                                function coordsBasic(t){
121                                                        var pos = dojo.position("sq100", false);
122                                                        // console.debug(pos);
123                                                        doh.is(100, pos.x);
124                                                        doh.is(100, pos.y);
125                                                        doh.is(100, pos.w);
126                                                        doh.is(100, pos.h);
127                                                },
128                                                function coordsMargin(t){
129                                                        // position() is getting us the border-box location
130                                                        var pos = dojo.position("sq100margin10", false);
131                                                        doh.is(260, pos.x);
132                                                        doh.is(110, pos.y);
133                                                        doh.is(100, pos.w);
134                                                        doh.is(100, pos.h);
135                                                        pos = dojo.marginBox("sq100margin10");
136                                                        doh.is(120, pos.w);
137                                                        doh.is(120, pos.h);
138                                                        // Though coords shouldn't be used, test it for backward compatibility.
139                                                        // coords returns the border-box location and margin-box size
140                                                        pos = dojo.coords("sq100margin10", false);
141                                                        doh.is(260, pos.x);
142                                                        doh.is(110, pos.y);
143                                                        doh.is(120, pos.w);
144                                                        doh.is(120, pos.h);
145                                                },
146                                                function coordsBorder(t){
147                                                        var pos = dojo.position("sq100border10", false);
148                                                        doh.is(100, pos.x);
149                                                        doh.is(400, pos.y);
150                                                },
151                                                function sq100nopos(t){
152                                                        var pos = dojo.position("sq100nopos", false);
153                                                        // console.debug(pos);
154                                                        doh.is(0, pos.x);
155                                                        doh.t(pos.y > 0);
156                                                        // FIXME: the 'correct' w is not 100 on Safari WebKit (2.0.4 [419.3]), the right-margin extends to the document edge
157                                                        // doh.is(100, pos.w);
158                                                        doh.is(100, pos.h);
159                                                },
160                                                function coordsScrolled(t) {
161                                                        var s = document.createElement('div');
162                                                        var c = document.createElement('div');
163                                                        document.body.appendChild(s);
164                                                        s.appendChild(c);
165                                                        var x=257, y= 285;
166                                                        with (s.style) {
167                                                                position = 'absolute';
168                                                                overflow = 'scroll';
169                                                                border = "10px solid black";
170                                                        }
171                                                        dojo._setMarginBox(s, x, y, 100, 100);
172                                                        dojo._setMarginBox(c, 0, 0, 500, 500);
173                                                        s.scrollTop = 200;
174                                                        var pos = dojo.position(s, true);
175                                                        doh.is(x, pos.x);
176                                                        doh.is(y, pos.y);
177                                                },
178                                                {
179                                                        name: "coordsIframe",
180                                                        timeout: 2000,
181                                                        runTest: function(){
182                                                                var def = new doh.Deferred();
183                                                                setTimeout(function(){ try{
184                                                                        var oldLtr = dojo._isBodyLtr();
185                                                                        var oldQuirks = dojo.isQuirks;
186                                                                        dojo.withGlobal(dojo.byId('iframe_quirks').win, function(){
187                                                                                doh.t(dojo.isQuirks, "isQuirks == true in quirks/iframe");
188                                                                                doh.f(dojo._isBodyLtr(), "isBodyLtr == false in RTL/iframe");
189                                                                                var pos = dojo.position('iframe_00_quirks');
190                                                                                doh.t(pos.x===0, "quirks iframe element x == 0 (x,y,w,h="+pos.x+","+pos.y+","+pos.w+","+pos.h+")");
191                                                                                doh.t(pos.y===0, "quirks iframe element y == 0 (x,y,w,h="+pos.x+","+pos.y+","+pos.w+","+pos.h+")");
192                                                                                doh.t(pos.w>0, "quirks iframe element w > 0 (x,y,w,h="+pos.x+","+pos.y+","+pos.w+","+pos.h+")");
193                                                                                doh.t(pos.h>0, "quirks iframe element h > 0 (x,y,w,h="+pos.x+","+pos.y+","+pos.w+","+pos.h+")");
194                                                                        });
195                                                                        dojo.withGlobal(dojo.byId('iframe_strict').win, function(){
196                                                                                doh.f(dojo.isQuirks, "isQuirks == false in strict/ifraee");
197                                                                                doh.f(dojo._isBodyLtr(), "isBodyLtr == false in RTL/iframe");
198                                                                                var pos = dojo.position('iframe_00_strict');
199                                                                                doh.t(pos.x===0, "strict iframe element x == 0 (x,y,w,h="+pos.x+","+pos.y+","+pos.w+","+pos.h+")");
200                                                                                doh.t(pos.y===0, "strict iframe element y == 0 (x,y,w,h="+pos.x+","+pos.y+","+pos.w+","+pos.h+")");
201                                                                                doh.t(pos.w>0, "strict iframe element w > 0 (x,y,w,h="+pos.x+","+pos.y+","+pos.w+","+pos.h+")");
202                                                                                doh.t(pos.h>0, "strict iframe element h > 0 (x,y,w,h="+pos.x+","+pos.y+","+pos.w+","+pos.h+")");
203                                                                        });
204                                                                        doh.t(!oldLtr == !dojo._isBodyLtr(), "isBodyLtr restored after withGlobal");
205                                                                        doh.t(!oldQuirks == !dojo.isQuirks, "isQuirks restored after withGlobal");
206                                                                        def.callback(true);
207                                                                }catch(e){ def.errback(e); } }, 1000);
208                                                                return def;
209                                                        }
210                                                },
211                                                "doh.is(1, dojo.style('sq100nopos', 'opacity'));",
212                                                "doh.is(0.1, dojo.style('sq100nopos', 'opacity', 0.1));",
213                                                "doh.is(0.8, dojo.style('sq100nopos', 'opacity', 0.8));",
214                                                function styleObject(){
215                                                        dojo.style('sq100nopos', { 'opacity': 0.1 });
216                                                        doh.is(0.1, dojo.style('sq100nopos', 'opacity'));
217                                                        dojo.style('sq100nopos', { 'opacity': 0.8 });
218                                                        doh.is(0.8, dojo.style('sq100nopos', 'opacity'));
219                                                },
220                                                "doh.is('static', dojo.style('sq100nopos', 'position'));",
221                                                function getBgcolor(t){
222                                                        var bgc = dojo.style('sq100nopos', 'backgroundColor');
223                                                        doh.t((bgc == "rgb(0, 0, 0)")||(bgc == "black")||(bgc == "#000000"));
224                                                },
225                                                function isDescendant(t){
226                                                        doh.t(dojo.isDescendant("sq100", dojo.body()));
227                                                        doh.t(dojo.isDescendant("sq100", dojo.doc));
228                                                        doh.t(dojo.isDescendant("sq100", "sq100"));
229                                                        doh.t(dojo.isDescendant(dojo.byId("sq100"), "sq100"));
230                                                        doh.f(dojo.isDescendant("sq100", dojo.byId("sq100").firstChild));
231                                                        doh.t(dojo.isDescendant(dojo.byId("sq100").firstChild, "sq100"));
232                                                },
233                                                function isDescendantIframe(t){
234                                                        var bif = dojo.byId("blah");
235                                                        // this test barely makes sense. disabling it for now.
236                                                        // doh.t(dojo.isDescendant(bif.contentDocument.getElementById("subDiv"), bif.parentNode));
237                                                        var subDiv = getIframeDocument(bif).getElementById("subDiv");
238                                                        doh.t(dojo.isDescendant(subDiv, subDiv));
239                                                        doh.t(dojo.isDescendant(subDiv, subDiv.parentNode));
240                                                        doh.f(dojo.isDescendant(subDiv.parentNode, subDiv));
241
242                                                },
243                                                function testClassFunctions(t){
244                                                        var node = dojo.byId("sq100");
245                                                        dojo.addClass(node, "a");
246                                                        doh.is("a", node.className, "class is a");
247                                                        dojo.removeClass(node, "c");
248                                                        doh.is("a", node.className, "class is still a");
249                                                        t.assertTrue(dojo.hasClass(node, "a"), "class is a, test for a");
250                                                        t.assertFalse(dojo.hasClass(node, "b"), "class is a, test for b");
251                                                        dojo.addClass(node, "b");
252                                                        doh.is("a b", node.className, "class is a b");
253                                                        t.assertTrue(dojo.hasClass(node, "a"), "class is a b, test for a");
254                                                        t.assertTrue(dojo.hasClass(node, "b"), "class is a b, test for b");
255                                                        dojo.removeClass(node, "a");
256                                                        doh.is("b", node.className, "class is b");
257                                                        t.assertFalse(dojo.hasClass(node, "a"), "class is b, test for a");
258                                                        t.assertTrue(dojo.hasClass(node, "b"), "class is b, test for b");
259                                                        dojo.toggleClass(node, "a");
260                                                        doh.is("b a", node.className, "class is b a");
261                                                        t.assertTrue(dojo.hasClass(node, "a"), "class is b a, test for a");
262                                                        t.assertTrue(dojo.hasClass(node, "b"), "class is b a, test for b");
263                                                        dojo.toggleClass(node, "a");
264                                                        doh.is("b", node.className, "class is b (again)");
265                                                        t.assertFalse(dojo.hasClass(node, "a"), "class is b (again), test for a");
266                                                        t.assertTrue(dojo.hasClass(node, "b"), "class is b (again), test for b");
267                                                        dojo.toggleClass(node, "b");
268                                                        doh.is("", node.className, "class is blank");
269                                                        t.assertFalse(dojo.hasClass(node, "a"), "class is blank, test for a");
270                                                        t.assertFalse(dojo.hasClass(node, "b"), "class is blank, test for b");
271                                                        dojo.removeClass(node, "c");
272                                                        t.assertTrue(!node.className, "no class");
273                                                },
274                                                function testAddRemoveClassMultiple(t){
275                                                        var node = dojo.byId("sq100");
276                                                        dojo.addClass(node, "a");
277                                                        t.is("a", node.className, "class is a");
278                                                        dojo.addClass(node, "a b");
279                                                        t.is("a b", node.className, "class is a b");
280                                                        dojo.addClass(node, "b a");
281                                                        t.is("a b", node.className, "class is still a b");
282                                                        dojo.addClass(node, ["a", "c"]);
283                                                        t.is("a b c", node.className, "class is a b c");
284                                                        dojo.removeClass(node, "c a");
285                                                        t.is("b", node.className, "class is b");
286                                                        dojo.removeClass(node);
287                                                        t.is("", node.className, "empty class");
288                                                        dojo.addClass(node, "  c   b   a ");
289                                                        t.is("c b a", node.className, "class is c b a");
290                                                        dojo.removeClass(node, " c b ");
291                                                        t.is("a", node.className, "class is a");
292                                                        dojo.removeClass(node, ["a", "c"]);
293                                                        t.is("", node.className, "empty class");
294                                                },
295                                                function getTypeInput(t){
296                                                        doh.f(dojo.hasAttr(dojo.byId("input-no-type"), "type"));
297                                                        doh.is(null, dojo.attr(dojo.byId("input-no-type"), "type"));
298                                                        doh.t(dojo.hasAttr(dojo.byId("input-with-type"), "type"));
299                                                        doh.is("checkbox", dojo.attr(dojo.byId("input-with-type"), "type"));
300                                                },
301                                                function getWithString(t){
302                                                        doh.f(dojo.hasAttr("input-no-type", "type"));
303                                                        doh.is(null, dojo.attr("input-no-type", "type"));
304                                                        doh.t(dojo.hasAttr("input-with-type", "type"));
305                                                        doh.is("checkbox", dojo.attr("input-with-type", "type"));
306                                                },
307                                                function attrId(t){
308                                                        doh.t(dojo.hasAttr("div-no-tabindex", "id"));
309                                                        doh.is("div-no-tabindex", dojo.attr("div-no-tabindex", "id"));
310                                                        var div = document.createElement("div");
311                                                        doh.f(dojo.hasAttr(div, "id"));
312                                                        doh.is(null, dojo.attr(div, "id"));
313                                                        dojo.attr(div, "id", "attrId1");
314                                                        doh.t(dojo.hasAttr(div, "id"));
315                                                        doh.is("attrId1", dojo.attr(div, "id"));
316                                                        dojo.removeAttr(div, "id");
317                                                        doh.f(dojo.hasAttr(div, "id"));
318                                                        doh.is(null, dojo.attr(div, "id"));
319                                                },
320                                                function getTabindexDiv(t){
321                                                        doh.f(dojo.hasAttr("div-no-tabindex", "tabIndex"));
322                                                        doh.t(dojo.attr("div-no-tabindex", "tabIndex") <= 0);
323                                                        doh.t(dojo.hasAttr("div-tabindex-minus-1", "tabIndex"));
324                                                        if(!dojo.isOpera){
325                                                                // Opera (at least <= 9) does not support tabIndex="-1"
326                                                                doh.is(-1, dojo.attr("div-tabindex-minus-1", "tabIndex"));
327                                                        }
328                                                        doh.t(dojo.hasAttr("div-tabindex-0", "tabIndex"));
329                                                        doh.is(0, dojo.attr("div-tabindex-0", "tabIndex"));
330                                                        doh.is(1, dojo.attr("div-tabindex-1", "tabIndex"));
331                                                },
332                                                function getTabindexInput(t){
333                                                        if(!dojo.isIE || dojo.isIE >= 8){
334                                                                // IE6/7 always reports tabIndex as defined
335                                                                doh.f(dojo.hasAttr("input-no-tabindex", "tabIndex"));
336                                                                doh.f(dojo.attr("input-no-tabindex", "tabIndex"));
337                                                        }
338                                                        doh.t(dojo.hasAttr("input-tabindex-minus-1", "tabIndex"));
339                                                        if(!dojo.isOpera){
340                                                                // Opera (at least <= 9) does not support tabIndex="-1"
341                                                                doh.is(-1, dojo.attr("input-tabindex-minus-1", "tabIndex"));
342                                                        }
343                                                        doh.t(dojo.hasAttr("input-tabindex-0", "tabIndex"));
344                                                        doh.is(0, dojo.attr("input-tabindex-0", "tabIndex"));
345                                                        doh.is(1, dojo.attr("input-tabindex-1", "tabIndex"));
346                                                },
347                                                function setTabindexDiv(t){
348                                                        var div = document.createElement("div");
349                                                        doh.is(null, dojo.attr(div, "tabIndex"));
350                                                        dojo.attr(div, "tabIndex", -1);
351                                                        if(!dojo.isOpera){
352                                                                // Opera (at least <= 9) does not support tabIndex="-1"
353                                                                doh.is(-1, dojo.attr(div, "tabIndex"));
354                                                        }
355                                                        dojo.attr(div, "tabIndex", 0);
356                                                        doh.is(0, dojo.attr(div, "tabIndex"));
357                                                        dojo.attr(div, "tabIndex", 1);
358                                                        doh.is(1, dojo.attr(div, "tabIndex"));
359                                                },
360                                                function setTabindexInput(t){
361                                                        var input = document.createElement("input");
362                                                        doh.t(dojo.attr(input, "tabIndex") <= 0);
363                                                        dojo.attr(input, "tabIndex", -1);
364                                                        if(!dojo.isOpera){
365                                                                // Opera (at least <= 9) does not support tabIndex="-1"
366                                                                doh.is(-1, dojo.attr(input, "tabIndex"));
367                                                        }
368                                                        dojo.attr(input, "tabIndex", 0);
369                                                        doh.is(0, dojo.attr(input, "tabIndex"));
370                                                        dojo.attr(input, "tabIndex", 1);
371                                                        doh.is(1, dojo.attr(input, "tabIndex"));
372                                                },
373                                                function removeTabindexFromDiv(t){
374                                                        var div = document.createElement("div");
375                                                        dojo.attr(div, "tabIndex", 1);
376                                                        doh.is(1, dojo.attr(div, "tabIndex"));
377                                                        dojo.removeAttr(div, "tabIndex");
378                                                        doh.is(null, dojo.attr(div, "tabIndex"));
379                                                },
380                                                function removeDisabledFromInput(t){
381                                                        var input = document.createElement("input");
382                                                        dojo.attr(input, "disabled", true);
383                                                        doh.t(dojo.attr(input, "disabled"));
384                                                        dojo.removeAttr(input, "disabled");
385                                                        doh.f(dojo.attr(input, "disabled"));
386                                                },
387                                                function removeTabindexFromInput(t){
388                                                        var input = document.createElement("input");
389                                                        dojo.attr(input, "tabIndex", 1);
390                                                        doh.is(1, dojo.attr(input, "tabIndex"));
391                                                        dojo.removeAttr(input, "tabIndex");
392                                                        doh.is(null, dojo.attr(input, "tabIndex"));
393                                                },
394                                                function setReadonlyInput(t){
395                                                        var input = document.createElement("input");
396                                                        doh.f(dojo.attr(input, "readonly"));
397                                                        dojo.attr(input, "readonly", true);
398                                                        doh.is(true, dojo.attr(input, "readonly"));
399                                                        dojo.attr(input, "readonly", false);
400                                                        doh.is(false, dojo.attr(input, "readonly"));
401                                                },
402                                                function attr_map(t){
403                                                        var input = document.createElement("input");
404                                                        var ctr= 0;
405                                                        dojo.attr(input, {
406                                                                "class": "thinger blah",
407                                                                "tabIndex": 1,
408                                                                "type": "text",
409                                                                "onfocus": function(e){
410                                                                        ctr++;
411                                                                }
412                                                        });
413                                                        dojo.body().appendChild(input);
414                                                        doh.is(1, dojo.attr(input, "tabIndex"), "tabIndex");
415                                                        if(!dojo.isIE || dojo.isIE > 7){
416                                                                // IE6/7 treats type="text" as missing, even if it was
417                                                                // explicitly specified
418                                                                doh.is("text", dojo.attr(input, "type"), "type");
419                                                        }
420                                                        doh.is(0, ctr, "onfocus ctr == 0");
421                                                        doh.t(dojo.hasClass(input, "thinger"), "hasClass of thinger");
422                                                        doh.t(dojo.hasClass(input, "blah"), "hasClass of blah");
423                                                        var def = new doh.Deferred();
424                                                        input.focus();
425                                                        setTimeout(function(){
426                                                                doh.is(1, ctr, "onfocus ctr == 1");
427                                                                input.blur();
428                                                                input.focus();
429                                                                setTimeout(function(){
430                                                                        doh.is(2, ctr, "onfocus ctr == 2");
431                                                                        def.callback(true);
432                                                                }, 10);
433                                                        }, 10);
434                                                        return def;
435                                                },
436                                                function attr_reconnect(t){
437                                                        var input = document.createElement("input");
438                                                        var ctr = 0;
439                                                        dojo.attr(input, "type", "text");
440                                                        dojo.attr(input, "onfocus", function(e){ ctr++; });
441                                                        dojo.attr(input, "onfocus", function(e){ ctr++; });
442                                                        dojo.attr(input, "onfocus", function(e){ ctr++; });
443                                                        dojo.body().appendChild(input);
444                                                        if(!dojo.isIE || dojo.isIE > 7){
445                                                                // IE6/7 treats type="text" as missing, even if it was
446                                                                // explicitly specified
447                                                                doh.is("text", dojo.attr(input, "type"));
448                                                        }
449                                                        doh.is(0, ctr);
450                                                        var def = new doh.Deferred();
451                                                        input.focus();
452                                                        setTimeout(function(){
453                                                                doh.is(1, ctr);
454                                                                input.blur();
455                                                                input.focus();
456                                                                setTimeout(function(){
457                                                                        doh.is(2, ctr);
458                                                                        def.callback(true);
459                                                                }, 10);
460                                                        }, 10);
461                                                        return def;
462                                                },
463                                                function attrSpecials(){
464                                                        var node = document.createElement("div");
465                                                        dojo.body().appendChild(node);
466                                                        dojo.attr(node, {
467                                                                style: {
468                                                                        opacity: 0.5,
469                                                                        width: "30px",
470                                                                        border: "1px solid black"
471                                                                }
472                                                        });
473                                                        doh.is(0.5, dojo.style(node, "opacity"));
474                                                        doh.is(30, dojo.style(node, "width"));
475                                                        doh.is(1, dojo.style(node, "borderWidth"));
476                                                        dojo.attr(node, {
477                                                                innerHTML: "howdy!"
478                                                        });
479                                                        doh.is("howdy!", node.innerHTML);
480                                                        doh.is("howdy!", dojo.attr(node, "innerHTML"));
481                                                        dojo.attr(node, "innerHTML", "<span>howdy!</span>");
482                                                        doh.is(1, node.firstChild.nodeType);
483                                                        doh.is("span", node.firstChild.nodeName.toLowerCase());
484                                                        doh.is("<span>howdy!</span>", node.innerHTML.toLowerCase());
485                                                        doh.is("<span>howdy!</span>", dojo.attr(node, "innerHTML").toLowerCase());
486                                                },
487                                                function testLabelForAttr(t){
488                                                        // create label with no for attribute make sure requesting
489                                                        // it as for and html for returns null
490                                                        var label = document.createElement("label");
491                                                        if(!dojo.isIE){
492                                                                // IE always assumes that "for" is present
493                                                                doh.f(dojo.attr(label, "for"));
494                                                                doh.f(dojo.attr(label, "htmlFor"));
495                                                        }
496                                                        // add a for attribute and test that can get by requesting for
497                                                        dojo.attr(label, "for", "testId");
498                                                        doh.is("testId", dojo.attr(label, "for"));
499                                                        // add as htmlFor and make sure it is returned when requested as htmlFor
500                                                        var label2 = document.createElement("label");
501                                                        dojo.attr(label2, "htmlFor", "testId2");
502                                                        doh.is("testId2", dojo.attr(label2, "htmlFor"));
503                                                        // check than when requested as for or htmlFor attribute is found
504                                                        doh.t(dojo.hasAttr(label, "for"));
505                                                        doh.t(dojo.hasAttr(label2, "htmlfor"));
506                                                        // test from markup
507                                                        var labelNoFor = dojo.byId("label-no-for");
508                                                        // make sure testing if has attribute using for or htmlFor
509                                                        // both return null when no value set
510                                                        if(!dojo.isIE){
511                                                                // IE always assumes that "for" is present
512                                                                doh.f(dojo.hasAttr(labelNoFor, "for"));
513                                                                doh.f(dojo.hasAttr(labelNoFor, "htmlFor"));
514                                                        }
515                                                        var labelWithFor = dojo.byId("label-with-for");
516                                                        // when markup includes for make certain testing if has attribute
517                                                        // using for or htmlFor returns true
518                                                        doh.t(dojo.hasAttr(labelWithFor, "for"));
519                                                        doh.t(dojo.hasAttr(labelWithFor, "htmlFor"));
520                                                        // when markup include for attrib make sure can retrieve using for or htmlFor
521                                                        doh.is("input-with-label", dojo.attr(labelWithFor, "for"));
522                                                        doh.is("input-with-label", dojo.attr(labelWithFor, "htmlFor"));
523                                                },
524                                                function attrInnerHtmlDiv(t){
525                                                        var n = dojo.create("div", {
526                                                                        innerHTML: "1<em>2</em>3"
527                                                                }, dojo.body());
528                                                        doh.is("1<em>2</em>3", n.innerHTML.toLowerCase());
529                                                        dojo.destroy(n);
530                                                },
531                                                function attrInnerHtmlTable(t){
532                                                        var n = dojo.create("table", {
533                                                                        innerHTML: "<thead><tr><th>1st!</th></tr></thead><tbody></tbody>"
534                                                                }, dojo.body());
535                                                        doh.is("<thead><tr><th>1st!</th></tr></thead><tbody></tbody>",
536                                                                n.innerHTML.toLowerCase().replace(/\s+/g, ""));
537                                                        dojo.destroy(n);
538                                                },
539                                                function attrInputTextValue(t){
540                                                        doh.is("123", dojo.byId("input-text-value").value);
541                                                        doh.is("123", dojo.attr("input-text-value", "value"));
542                                                        dojo.attr("input-text-value", "value", "abc");
543                                                        doh.is("abc", dojo.byId("input-text-value").value);
544                                                        doh.is("abc", dojo.attr("input-text-value", "value"));
545                                                        dojo.byId("input-text-value").value = "xyz";
546                                                        doh.is("xyz", dojo.byId("input-text-value").value);
547                                                        doh.is("xyz", dojo.attr("input-text-value", "value"));
548                                                        dojo.byId("input-text-value").value = "123"; // fixes initialization problem when the test is reloaded
549                                                },
550                                                function testInputDisabled(t){
551                                                        doh.f(dojo.attr("input-no-disabled", "disabled"));
552                                                        doh.t(dojo.attr("input-with-disabled", "disabled"));
553                                                        doh.t(dojo.attr("input-with-disabled-true", "disabled"));
554                                                },
555                                                function testIframeDestroy10095(t){
556                                                        var iframeWin = dojo.byId('10095_iframe').win;
557                                                        doh.t(!iframeWin.document.getElementById('10095_textbox'), "reloaded iframe element destroyed");
558                                                }
559                                        ]
560                                );
561                                doh.run();
562                        });
563                </script>
564                <style type="text/css">
565                        html, body {
566                                padding: 0px;
567                                margin: 0px;
568                                border: 0px;
569                        }
570
571                        #sq100 {
572                                background-color: black;
573                                color: white;
574                                position: absolute;
575                                left: 100px;
576                                top: 100px;
577                                width: 100px;
578                                height: 100px;
579                                border: 0px;
580                                padding: 0px;
581                                margin: 0px;
582                                overflow: hidden;
583                        }
584
585                        #sq100margin10 {
586                                background-color: black;
587                                color: white;
588                                position: absolute;
589                                left: 250px;
590                                top: 100px;
591                                width: 100px;
592                                height: 100px;
593                                border: 0px;
594                                padding: 0px;
595                                margin: 10px;
596                                overflow: hidden;
597                        }
598
599                        #sq100margin10pad10 {
600                                background-color: black;
601                                color: white;
602                                position: absolute;
603                                left: 400px;
604                                top: 100px;
605                                width: 100px;
606                                height: 100px;
607                                border: 0px;
608                                padding: 10px;
609                                margin: 10px;
610                                overflow: hidden;
611                        }
612
613                        #sq100pad10 {
614                                background-color: black;
615                                color: white;
616                                position: absolute;
617                                left: 100px;
618                                top: 250px;
619                                width: 100px;
620                                height: 100px;
621                                border: 0px;
622                                padding: 10px;
623                                margin: 0px;
624                                overflow: hidden;
625                        }
626
627                        #sq100ltpad10 {
628                                background-color: black;
629                                color: white;
630                                position: absolute;
631                                left: 250px;
632                                top: 250px;
633                                width: 100px;
634                                height: 100px;
635                                border: 0px;
636                                padding-left: 10px;
637                                padding-top: 10px;
638                                padding-right: 0px;
639                                padding-bottom: 0px;
640                                margin: 0px;
641                                overflow: hidden;
642                        }
643
644                        #sq100ltpad10rbmargin10 {
645                                background-color: black;
646                                color: white;
647                                position: absolute;
648                                left: 400px;
649                                top: 250px;
650                                width: 100px;
651                                height: 100px;
652                                border: 0px;
653                                padding-left: 10px;
654                                padding-top: 10px;
655                                padding-right: 0px;
656                                padding-bottom: 0px;
657                                margin-left: 0px;
658                                margin-top: 0px;
659                                margin-right: 10px;
660                                margin-bottom: 10px;
661                                overflow: hidden;
662                        }
663
664                        #sq100border10 {
665                                background-color: black;
666                                color: white;
667                                position: absolute;
668                                left: 100px;
669                                top: 400px;
670                                width: 100px;
671                                height: 100px;
672                                border: 10px solid yellow;
673                                padding: 0px;
674                                margin: 0px;
675                                overflow: hidden;
676                        }
677
678                        #sq100border10margin10 {
679                                background-color: black;
680                                color: white;
681                                position: absolute;
682                                left: 250px;
683                                top: 400px;
684                                width: 100px;
685                                height: 100px;
686                                border: 10px solid yellow;
687                                padding: 0px;
688                                margin: 10px;
689                                overflow: hidden;
690                        }
691
692                        #sq100border10margin10pad10 {
693                                background-color: black;
694                                color: white;
695                                position: absolute;
696                                left: 400px;
697                                top: 400px;
698                                width: 100px;
699                                height: 100px;
700                                border: 10px solid yellow;
701                                padding: 10px;
702                                margin: 10px;
703                                overflow: hidden;
704                        }
705
706                        #sq100nopos {
707                                background-color: black;
708                                color: white;
709                                width: 100px;
710                                height: 100px;
711                                padding: 0px;
712                                margin: 0px;
713                        }
714
715                </style>
716        </head>
717        <body>
718                <h1>testing Core HTML/DOM/CSS/Style utils</h1>
719                <div id="sq100">
720                        100px square, abs
721                </div>
722                <div id="sq100margin10">
723                        100px square, abs, 10px margin
724                </div>
725                <div id="sq100margin10pad10">
726                        100px square, abs, 10px margin, 10px padding
727                </div>
728                <div id="sq100pad10">
729                        100px square, abs, 10px padding
730                </div>
731                <div id="sq100ltpad10">
732                        100px square, abs, 10px left and top padding
733                </div>
734                <div id="sq100ltpad10rbmargin10">
735                        100px square, abs, 10px left and top padding, 10px bottom and right margin
736                </div>
737                <div id="sq100border10">
738                        100px square, abs, 10px yellow border
739                </div>
740                <div id="sq100border10margin10">
741                        100px square, abs, 10px yellow border, 10px margin
742                </div>
743                <div id="sq100border10margin10pad10">
744                        100px square, abs, 10px yellow border, 10px margin, 10px padding
745                </div>
746                <div id="sq100nopos">
747                        100px square, no positioning
748                </div>
749
750                <iframe id="blah" name="blah" src="javascript:'&lt;html&gt&lt;body&gt;&lt;div id=subDiv&gt;&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;'"></iframe>
751
752                <script type="text/javascript">
753                var reloaded = false;
754                function iframe10095loaded() {
755                        var iframeWin = dojo.byId('10095_iframe').win;
756                        dojo.withGlobal(iframeWin, function(){ dojo.destroy(dojo.byId('10095_textbox')) });
757                        if(!reloaded){
758                                reloaded = true;
759                                dojo.byId('10095_iframe').src=iframeWin.frameElement.src;
760                        }
761                }
762                </script>
763                <iframe id="10095_iframe" style="display:none;" src="javascript:'&lt;html&gt;&lt;head&gt;&lt;script&gt;frameElement.win=window&lt;/script&gt;&lt;/head&gt;&lt;body&gt;&lt;input id=10095_textbox&gt;&lt;/body&gt;&lt;/html&gt;'" onload="dojo.addOnLoad(iframe10095loaded)"></iframe>
764
765                <div id='iframe_div' style="position:absolute;top:0;left:500px;"></div>
766
767                <div id="div-no-tabindex"></div>
768                <div id="div-tabindex-minus-1" tabIndex="-1"></div>
769                <div id="div-tabindex-0" tabIndex="0"></div>
770                <div id="div-tabindex-1" tabIndex="1"></div>
771
772                <div>
773                        <input id="input-no-type">
774                        <input id="input-with-type" type="checkbox">
775                        <input id="input-no-tabindex">
776                        <input id="input-tabindex-minus-1" tabIndex="-1">
777                        <input id="input-tabindex-0" tabIndex="0">
778                        <input id="input-tabindex-1" tabIndex="1">
779                        <input id="input-text-value" type="text" value="123">
780                        <input id="input-no-disabled" type="text">
781                        <input id="input-with-disabled" type="text" disabled>
782                        <input id="input-with-disabled-true" disabled="disabled">
783                </div>
784                <div>
785                        <label id="label-no-for">label with no for </label><input type="text" id="label-test-input">
786                        <label id="label-with-for" for="input-with-label">label with for </label><input type="text" id="input-with-label">
787                </div>
788        </body>
789</html>
790
Note: See TracBrowser for help on using the browser.