| 1 |
<!DOCTYPE html> |
| 2 |
<html lang="en"> |
| 3 |
<head> |
| 4 |
<meta http-equiv="Content-type" content="text/html; charset=utf-8"> |
| 5 |
<title>ContentPane layout-related DOH test</title> |
| 6 |
<style type="text/css"> |
| 7 |
.resizableWidget { |
| 8 |
border: 1px dashed red; |
| 9 |
background-color: #C0E209; |
| 10 |
} |
| 11 |
</style> |
| 12 |
|
| 13 |
<script type="text/javascript" src="../boilerplate.js"></script> |
| 14 |
|
| 15 |
|
| 16 |
<script type="text/javascript"> |
| 17 |
require([ |
| 18 |
"doh/runner", |
| 19 |
"dojo/_base/array", |
| 20 |
"dojo/aspect", |
| 21 |
"dojo/_base/declare", |
| 22 |
"dojo/dom-geometry", |
| 23 |
"dojo/store/Memory", |
| 24 |
"dojo/parser", |
| 25 |
"dijit/registry", |
| 26 |
"dijit/_WidgetBase", |
| 27 |
"dijit/_TemplatedMixin", |
| 28 |
"dijit/Dialog", |
| 29 |
"dijit/form/ComboBox", |
| 30 |
"dijit/form/Form", |
| 31 |
"dijit/layout/BorderContainer", |
| 32 |
"dijit/layout/ContentPane", |
| 33 |
"dijit/layout/_LayoutWidget", |
| 34 |
"dijit/layout/TabContainer", |
| 35 |
"dijit/TitlePane", |
| 36 |
"dojo/domReady!" |
| 37 |
], function(doh, array, aspect, declare, domGeom, Memory, parser, |
| 38 |
registry, _WidgetBase, _TemplatedMixin, |
| 39 |
Dialog, Form, BorderContainer, ContentPane, _LayoutWidget, TabContainer, TitlePane){ |
| 40 |
|
| 41 |
// Keep track of which panes have had a load event, and how |
| 42 |
// many load events have occurred for those panes |
| 43 |
var loadEvents = { |
| 44 |
}; |
| 45 |
myOnLoad = function(){ |
| 46 |
console.log("onload for " + this); |
| 47 |
loadEvents[this.id] = (loadEvents[this.id] || 0) + 1; |
| 48 |
}; |
| 49 |
|
| 50 |
// create a do nothing, only for test widget |
| 51 |
declare("ResizableWidget", [_WidgetBase, _TemplatedMixin], { |
| 52 |
templateString: "<span class='dijitInline resizableWidget'>resizable widget</span>", |
| 53 |
_resized: 0, |
| 54 |
_resizeArgs: null, |
| 55 |
|
| 56 |
constructor: function(){ |
| 57 |
this.history = []; |
| 58 |
}, |
| 59 |
|
| 60 |
startup: function(){ |
| 61 |
this.history.push("started"); |
| 62 |
}, |
| 63 |
|
| 64 |
resize: function(newSize){ |
| 65 |
this.history.push("resized"); |
| 66 |
this._resized++; |
| 67 |
this._resizeArgs = arguments; |
| 68 |
if(newSize){ |
| 69 |
domGeom.setMarginBox(this.domNode, newSize); |
| 70 |
} |
| 71 |
} |
| 72 |
}); |
| 73 |
|
| 74 |
// Monitor lifecycle of widgets. This used to be done by attaching to _WidgetBase.prototype and |
| 75 |
// _LayoutWidget.prototype, but that leads to race conditions since declare() runs first, and looks |
| 76 |
// at the original methods, not the advised-methods. |
| 77 |
var startups = {}; |
| 78 |
var layoutResizes = {}; |
| 79 |
aspect.after(registry, "add", function(widget){ |
| 80 |
// Keep track of the number of startup() calls to every widget. |
| 81 |
// Since the href's widgets haven't been created yet we monitor startup() calls on the prototype |
| 82 |
aspect.after(widget, "startup", function(){ |
| 83 |
startups[widget.id] = (startups[widget.id] || 0) + 1; |
| 84 |
}, true); |
| 85 |
|
| 86 |
// Keep track of which layout widgets each resize call to each layout widget, |
| 87 |
// specifically whether each call specified a size or not. |
| 88 |
// Since the href's widgets haven't been created yet we can't connect to their resize() |
| 89 |
// methods, but we can monitor resize() on the prototype |
| 90 |
aspect.after(widget, "resize", function(){ |
| 91 |
// this is the pointer to the widget, and arguments are newsize/curSize args to resize() |
| 92 |
var ary = layoutResizes[widget.id]; |
| 93 |
if(!ary){ |
| 94 |
ary = layoutResizes[widget.id] = []; |
| 95 |
} |
| 96 |
ary.push(arguments); |
| 97 |
}, true); |
| 98 |
}, true); |
| 99 |
|
| 100 |
doh.register("parse", function(){ |
| 101 |
return parser.parse(); |
| 102 |
}); |
| 103 |
|
| 104 |
// Test that ContentPanes calls startup() on child widgets appropriately |
| 105 |
// TODO: overlap here (and other places) with ContentPane.html? |
| 106 |
doh.register("startup events", |
| 107 |
{ |
| 108 |
name: "startup on href pane's children", |
| 109 |
timeout: 10000, |
| 110 |
runTest: function(){ |
| 111 |
var d = new doh.Deferred(); |
| 112 |
|
| 113 |
// Wait for load events to occur (after fetching URL's) |
| 114 |
var pane1 = registry.byId("pane1"); |
| 115 |
pane1.onLoadDeferred.then(d.getTestCallback(function(){ |
| 116 |
var children = pane1.getChildren(); |
| 117 |
doh.is(2, children.length, "found combobox and button"); |
| 118 |
doh.is(1, startups[children[0].id], "combobox started once"); |
| 119 |
doh.is(1, startups[children[0].id], "button started once"); |
| 120 |
})); |
| 121 |
|
| 122 |
// startup of layout widgets is tested below, indirectly, by |
| 123 |
// monitoring how man times resize is called etc. |
| 124 |
return d; |
| 125 |
} |
| 126 |
} |
| 127 |
); |
| 128 |
|
| 129 |
// Test that ContentPanes defer their load until they are shown |
| 130 |
doh.register("load events", [ |
| 131 |
{ |
| 132 |
name: "initial conditions", |
| 133 |
timeout: 10000, |
| 134 |
runTest: function(){ |
| 135 |
var d = new doh.Deferred(); |
| 136 |
// Wait for load events to occur (after fetching URL's) |
| 137 |
registry.byId("pane1").onLoadDeferred.then(d.getTestCallback(function(){ |
| 138 |
array.forEach(["pane2", "innerPane1", "innerPane2", "bcPane1", "bcPane2"], function(pane){ |
| 139 |
doh.f(loadEvents[pane], pane, pane + " shouldn't be loaded"); |
| 140 |
}); |
| 141 |
})); |
| 142 |
return d; |
| 143 |
} |
| 144 |
}, |
| 145 |
{ |
| 146 |
name: "reset href in hidden pane, pane2", |
| 147 |
timeout: 2000, |
| 148 |
runTest: function(){ |
| 149 |
// Resetting an href on a hidden pane should have no effect |
| 150 |
var d = new doh.Deferred(); |
| 151 |
|
| 152 |
registry.byId("pane2").set("href", "doc0.html"); |
| 153 |
setTimeout(d.getTestCallback(function(){ |
| 154 |
doh.f(loadEvents.pane2, "pane2 shouldn't be loaded"); |
| 155 |
}), 750); |
| 156 |
|
| 157 |
return d; |
| 158 |
} |
| 159 |
}, |
| 160 |
{ |
| 161 |
name: "reset href in hidden pane, innerPane1", |
| 162 |
timeout: 2000, |
| 163 |
runTest: function(){ |
| 164 |
// Resetting an href on a hidden pane should have no effect |
| 165 |
var d = new doh.Deferred(); |
| 166 |
|
| 167 |
registry.byId("innerPane1").set("href", "doc1.html"); |
| 168 |
setTimeout(d.getTestCallback(function(){ |
| 169 |
doh.f(loadEvents.innerPane1, "innerPane1 shouldn't be loaded"); |
| 170 |
}), 750); |
| 171 |
|
| 172 |
return d; |
| 173 |
} |
| 174 |
}, |
| 175 |
{ |
| 176 |
name: "reset href in hidden pane, bcPane2", |
| 177 |
timeout: 2000, |
| 178 |
runTest: function(){ |
| 179 |
// Resetting an href on a hidden pane should have no effect |
| 180 |
var d = new doh.Deferred(); |
| 181 |
|
| 182 |
registry.byId("bcPane2").set("href", "doc0.html"); |
| 183 |
setTimeout(d.getTestCallback(function(){ |
| 184 |
doh.f(loadEvents.bcPane2, "bcPane2 shouldn't be loaded"); |
| 185 |
}), 750); |
| 186 |
|
| 187 |
return d; |
| 188 |
} |
| 189 |
}, |
| 190 |
{ |
| 191 |
name: "selecting ContentPane causes it to load", |
| 192 |
timeout: 10000, |
| 193 |
runTest: function(){ |
| 194 |
var pane2 = registry.byId("pane2"); |
| 195 |
doh.f(pane2.onLoadDeferred.isResolved(), "pane2 not loaded yet"); |
| 196 |
registry.byId("outerTC").selectChild(pane2); |
| 197 |
return pane2.onLoadDeferred; |
| 198 |
} |
| 199 |
}, |
| 200 |
{ |
| 201 |
name: "selecting a TabContainer causes its selected child to load", |
| 202 |
timeout: 10000, |
| 203 |
runTest: function(){ |
| 204 |
var innerPane1 = registry.byId("innerPane1"); |
| 205 |
|
| 206 |
doh.f(innerPane1.onLoadDeferred.isResolved(), "innerPane1 not loaded yet"); |
| 207 |
|
| 208 |
registry.byId("outerTC").selectChild(registry.byId("innerTC")); |
| 209 |
|
| 210 |
return innerPane1.onLoadDeferred; |
| 211 |
} |
| 212 |
}, |
| 213 |
{ |
| 214 |
name: "selecting a BorderContainer causes its children to load", |
| 215 |
timeout: 10000, |
| 216 |
runTest: function(){ |
| 217 |
doh.f(registry.byId("bcPane1").onLoadDeferred.isResolved(), "bcPane1 not loaded"); |
| 218 |
doh.f(registry.byId("bcPane2").onLoadDeferred.isResolved(), "bcPane1 not loaded"); |
| 219 |
|
| 220 |
registry.byId("outerTC").selectChild(registry.byId("bc")); |
| 221 |
|
| 222 |
return registry.byId("bcPane1").onLoadDeferred.then(function(){ |
| 223 |
return registry.byId("bcPane2").onLoadDeferred; |
| 224 |
}); |
| 225 |
} |
| 226 |
} |
| 227 |
]); |
| 228 |
|
| 229 |
doh.register("resize events", [ |
| 230 |
// Test that when ContentPane w/single resizable child is shown, |
| 231 |
// the child is sized to match the ContentPane |
| 232 |
{ |
| 233 |
name: "single child", |
| 234 |
runTest: function(){ |
| 235 |
var child = registry.byId("singleChildResizable"); |
| 236 |
doh.is(0, child._resized, "hasn't been shown yet so no resize events"); |
| 237 |
|
| 238 |
registry.byId("resizeTC").selectChild(registry.byId("singleChildPane")); |
| 239 |
|
| 240 |
doh.t(child._resized, "got resize event"); // note: should only be 1 but currently gets 2 |
| 241 |
doh.t(child._resizeArgs && child._resizeArgs.length, "got size specified"); |
| 242 |
|
| 243 |
var size = child._resizeArgs[0]; |
| 244 |
doh.t(size && size.h, "non-0 height specified"); |
| 245 |
doh.t(size && size.w, "non-0 width specified"); |
| 246 |
} |
| 247 |
}, |
| 248 |
// Test that when ContentPane w/multiple resizable children is shown, |
| 249 |
// the children aren't sized to match the ContentPane, but we do call |
| 250 |
// resize on them so they can lay themselves out |
| 251 |
{ |
| 252 |
name: "multiple children", |
| 253 |
runTest: function(){ |
| 254 |
var child1 = registry.byId("multipleChildResizable1"), |
| 255 |
child2 = registry.byId("multipleChildResizable2"); |
| 256 |
|
| 257 |
doh.is(0, child1._resized, "child1 hasn't been shown yet so no resize events"); |
| 258 |
doh.is(0, child2._resized, "child2 hasn't been shown yet so no resize events"); |
| 259 |
|
| 260 |
registry.byId("resizeTC").selectChild(registry.byId("multipleChildPanes")); |
| 261 |
|
| 262 |
doh.t(child1._resized, "got resize event for child1"); |
| 263 |
doh.is(0, child1._resizeArgs && child1._resizeArgs.length, "no size specified for child1"); |
| 264 |
doh.t(child2._resized, "got resize event for child2"); |
| 265 |
doh.is(0, child2._resizeArgs && child2._resizeArgs.length, "no size specified for child2") |
| 266 |
} |
| 267 |
}, |
| 268 |
|
| 269 |
{ |
| 270 |
name: "single resizable widget, plus invisible widget", |
| 271 |
runTest: function(){ |
| 272 |
var child = registry.byId("fss2_rc"); |
| 273 |
doh.t(child._resized, "got resize event for child"); |
| 274 |
doh.is(1, child._resizeArgs && child._resizeArgs.length, "size specified"); |
| 275 |
doh.is("fss2_rc", registry.byId("fss2")._singleChild.id, "the resizable child memoed") |
| 276 |
} |
| 277 |
}, |
| 278 |
|
| 279 |
{ |
| 280 |
name: "multiple resizable widgets in form with size", |
| 281 |
runTest: function(){ |
| 282 |
var child1 = registry.byId("fsmc1"), |
| 283 |
child2 = registry.byId("fsmc2"); |
| 284 |
|
| 285 |
doh.t(child1._resized, "got resize event for child1"); |
| 286 |
doh.is(0, child1._resizeArgs && child1._resizeArgs.length, "no size specified for child1"); |
| 287 |
doh.t(child2._resized, "got resize event for child2"); |
| 288 |
doh.is(0, child2._resizeArgs && child2._resizeArgs.length, "no size specified for child2"); |
| 289 |
} |
| 290 |
}, |
| 291 |
{ |
| 292 |
name: "single resizable widget, single non-resizable (but visible) widget", |
| 293 |
runTest: function(){ |
| 294 |
var child = registry.byId("fsm2_rc"); |
| 295 |
doh.t(child._resized, "got resize event for child"); |
| 296 |
doh.is(0, child._resizeArgs && child._resizeArgs.length, "no size specified for child"); |
| 297 |
} |
| 298 |
}, |
| 299 |
|
| 300 |
// Test that resize event works correctly for href w/single layout widget |
| 301 |
{ |
| 302 |
name: "single resizable href", |
| 303 |
timeout: 10000, |
| 304 |
runTest: function(){ |
| 305 |
var d = new doh.Deferred(); |
| 306 |
var singleChildHref = registry.byId("singleChildHref"); |
| 307 |
|
| 308 |
registry.byId("resizeTC").selectChild(singleChildHref); |
| 309 |
|
| 310 |
// Wait for load events to occur (after fetching URL's) |
| 311 |
singleChildHref.onLoadDeferred.then(d.getTestCallback(function(){ |
| 312 |
// Check top level border container got sized to fit ContentPane |
| 313 |
var child = registry.byId("singleChildHrefBorderContainer"); |
| 314 |
doh.t(child, "href was loaded and top level BorderContainer was created"); |
| 315 |
doh.t(layoutResizes["singleChildHrefBorderContainer"], "got resize event"); |
| 316 |
doh.t(layoutResizes["singleChildHrefBorderContainer"][0].length, "got size specified"); |
| 317 |
|
| 318 |
var size = layoutResizes["singleChildHrefBorderContainer"][0][0]; |
| 319 |
doh.t(size && size.h, "non-0 height specified"); |
| 320 |
doh.t(size && size.w, "non-0 width specified"); |
| 321 |
|
| 322 |
// Check that resize() events also trickled down to inner TabContainer |
| 323 |
var child2 = registry.byId("singleChildHrefInnerTabContainer"); |
| 324 |
doh.t(child2, "inner TabContainer was created"); |
| 325 |
doh.t(layoutResizes["singleChildHrefInnerTabContainer"], "got resize event"); |
| 326 |
doh.is(0, layoutResizes["singleChildHrefInnerTabContainer"][0].length, "no size specified") |
| 327 |
})); |
| 328 |
|
| 329 |
return d; |
| 330 |
} |
| 331 |
}, |
| 332 |
|
| 333 |
// Test that resize event works correctly for href w/multiple layout widgets |
| 334 |
{ |
| 335 |
name: "multiple resizable href", |
| 336 |
timeout: 10000, |
| 337 |
runTest: function(){ |
| 338 |
var d = new doh.Deferred(); |
| 339 |
var multipleChildHref = registry.byId("multipleChildHref") |
| 340 |
|
| 341 |
registry.byId("resizeTC").selectChild(multipleChildHref); |
| 342 |
|
| 343 |
// Wait for load events to occur (after fetching URL's) |
| 344 |
multipleChildHref.onLoadDeferred.then(d.getTestCallback(function(){ |
| 345 |
// Check that resize() done on TabContainer |
| 346 |
var child = registry.byId("multipleChildHrefTabContainer"); |
| 347 |
doh.t(child, "TabContainer was created"); |
| 348 |
doh.t(layoutResizes["multipleChildHrefTabContainer"], "got resize event"); |
| 349 |
doh.is(0, layoutResizes["multipleChildHrefTabContainer"][0].length, "no size specified") |
| 350 |
})); |
| 351 |
|
| 352 |
return d; |
| 353 |
} |
| 354 |
}, |
| 355 |
|
| 356 |
// Test that resize() is called on resizable children hidden inside of a form widget |
| 357 |
// where the form widget is inside a layout container |
| 358 |
{ |
| 359 |
name: "multiple resizable elements hidden in form in TabContainer", |
| 360 |
runTest: function(){ |
| 361 |
var child1 = registry.byId("resizableInForm1"), |
| 362 |
child2 = registry.byId("resizableInForm2"); |
| 363 |
|
| 364 |
doh.is(0, child1._resized, "child1 hasn't been shown yet so no resize events"); |
| 365 |
doh.is(1, child1.history.length, "child1 # of history events (before show)"); |
| 366 |
doh.is("started", child1.history[0], "child1 history"); |
| 367 |
|
| 368 |
doh.is(0, child2._resized, "child2 hasn't been shown yet so no resize events"); |
| 369 |
doh.is(1, child1.history.length, "child2 # of history events (before show)"); |
| 370 |
doh.is("started", child2.history[0], "child2 history"); |
| 371 |
|
| 372 |
registry.byId("resizeTC").selectChild(registry.byId("multipleResizableInForm")); |
| 373 |
|
| 374 |
doh.t(child1._resized, "got resize event for child1"); |
| 375 |
doh.is(0, child1._resizeArgs && child1._resizeArgs.length, "no size specified for child1"); |
| 376 |
doh.t(child2._resized, "got resize event for child2"); |
| 377 |
doh.is(0, child2._resizeArgs && child2._resizeArgs.length, "no size specified for child2") |
| 378 |
} |
| 379 |
}, |
| 380 |
|
| 381 |
{ |
| 382 |
name: "single resizable element hidden in form in TabContainer", |
| 383 |
runTest: function(){ |
| 384 |
var child = registry.byId("resizableInForm0"); |
| 385 |
|
| 386 |
doh.is(0, child._resized, "child hasn't been shown yet so no resize events"); |
| 387 |
doh.is(1, child.history.length, "child # of history events (before show)"); |
| 388 |
doh.is("started", child.history[0], "child history"); |
| 389 |
|
| 390 |
registry.byId("resizeTC").selectChild(registry.byId("singleResizableInForm")); |
| 391 |
|
| 392 |
doh.t(child._resized, "got resize event for child"); |
| 393 |
doh.is(1, child._resizeArgs && child._resizeArgs.length, "size specified") |
| 394 |
} |
| 395 |
}, |
| 396 |
|
| 397 |
// Test that form where parent *isn't* a layout container calls startup() and resize() |
| 398 |
// on it's child layout widgets |
| 399 |
{ |
| 400 |
name: "single resizable element in form with size", |
| 401 |
runTest: function(){ |
| 402 |
var child = registry.byId("fssc"); |
| 403 |
doh.t(child._resized, "got resize event for child"); |
| 404 |
doh.is(1, child._resizeArgs && child._resizeArgs.length, "size specified") |
| 405 |
} |
| 406 |
}, |
| 407 |
|
| 408 |
{ |
| 409 |
name: "multiple resizable elements in form with size", |
| 410 |
runTest: function(){ |
| 411 |
var child1 = registry.byId("fsmc1"), |
| 412 |
child2 = registry.byId("fsmc2"); |
| 413 |
|
| 414 |
doh.t(child1._resized, "got resize event for child1"); |
| 415 |
doh.is(0, child1._resizeArgs && child1._resizeArgs.length, "no size specified for child1"); |
| 416 |
doh.t(child2._resized, "got resize event for child2"); |
| 417 |
doh.is(0, child2._resizeArgs && child2._resizeArgs.length, "no size specified for child2") |
| 418 |
} |
| 419 |
}, |
| 420 |
|
| 421 |
{ |
| 422 |
name: "single resizable elements in form with no size, doLayout=false", |
| 423 |
runTest: function(){ |
| 424 |
var child = registry.byId("fnsc"); |
| 425 |
|
| 426 |
doh.t(child._resized, "got resize event for child"); |
| 427 |
doh.is(0, child._resizeArgs && child._resizeArgs.length, "no size specified for child") |
| 428 |
} |
| 429 |
}, |
| 430 |
|
| 431 |
{ |
| 432 |
name: "multiple resizable elements in form with no size", |
| 433 |
runTest: function(){ |
| 434 |
var child1 = registry.byId("fnmc1"), |
| 435 |
child2 = registry.byId("fnmc2"); |
| 436 |
|
| 437 |
doh.t(child1._resized, "got resize event for child1"); |
| 438 |
doh.is(0, child1._resizeArgs && child1._resizeArgs.length, "no size specified for child1"); |
| 439 |
doh.t(child2._resized, "got resize event for child2"); |
| 440 |
doh.is(0, child2._resizeArgs && child2._resizeArgs.length, "no size specified for child2") |
| 441 |
} |
| 442 |
} |
| 443 |
]); |
| 444 |
|
| 445 |
// Make sure that TitlePane loads it's href at the appropriate time, and also that |
| 446 |
// it calls resize on it's children at the appropriate time (since that's the contract |
| 447 |
// for layout widgets, and ContentPane is acting as a layout widget). |
| 448 |
doh.register("TitlePane", [ |
| 449 |
/*** |
| 450 |
* test for #8197, uncomment when it's fixed. |
| 451 |
{ |
| 452 |
name: "initially open, single child", |
| 453 |
timeout: 2000, |
| 454 |
runTest: function(){ |
| 455 |
var d = new doh.Deferred(); |
| 456 |
|
| 457 |
var tp = registry.byId("otpHsc"); |
| 458 |
|
| 459 |
// Allow time for href to load |
| 460 |
setTimeout(d.getTestCallback(function(){ |
| 461 |
// Check that href loaded |
| 462 |
doh.is(1, loadEvents["otpHsc"], "otpHsc loaded on page load"); |
| 463 |
|
| 464 |
// Check that resize() done on child |
| 465 |
doh.t(layoutResizes["otpHscBorderContainer"], "got resize event"); |
| 466 |
doh.is(0, layoutResizes["otpHscBorderContainer"][0].length, "no size specified") |
| 467 |
}), 750); |
| 468 |
|
| 469 |
return d; |
| 470 |
} |
| 471 |
}, |
| 472 |
*/ |
| 473 |
{ |
| 474 |
name: "initially open, href multiple children", |
| 475 |
timeout: 10000, |
| 476 |
runTest: function(){ |
| 477 |
var d = new doh.Deferred(); |
| 478 |
|
| 479 |
var tp = registry.byId("otpHmc"); |
| 480 |
|
| 481 |
// Allow time for href to load |
| 482 |
tp.onLoadDeferred.then(d.getTestCallback(function(){ |
| 483 |
// Check that resize() done on children |
| 484 |
doh.t(layoutResizes["otpHmcBorderContainer"], "got resize event for BC"); |
| 485 |
doh.t(layoutResizes["otpHmcTabContainer"], "got resize event for TC"); |
| 486 |
doh.is(0, layoutResizes["otpHmcBorderContainer"][0].length, "no size specified for BC") |
| 487 |
})); |
| 488 |
|
| 489 |
return d; |
| 490 |
} |
| 491 |
}, |
| 492 |
|
| 493 |
{ |
| 494 |
name: "initially open, multiple children", |
| 495 |
runTest: function(){ |
| 496 |
var tp = registry.byId("otpMc"); |
| 497 |
|
| 498 |
// Check that resize() done on children |
| 499 |
doh.t(registry.byId("otpMc_child1")._resized, "got resize event for child1"); |
| 500 |
doh.t(registry.byId("otpMc_child2")._resized, "got resize event for child2"); |
| 501 |
} |
| 502 |
}, |
| 503 |
|
| 504 |
{ |
| 505 |
name: "initially closed, href multiple children", |
| 506 |
timeout: 10000, |
| 507 |
runTest: function(){ |
| 508 |
var d = new doh.Deferred(); |
| 509 |
|
| 510 |
doh.f(loadEvents["ctpHmc"], "ctpHmc load deferred until open"); |
| 511 |
|
| 512 |
var tp = registry.byId("ctpHmc"); |
| 513 |
tp.set("open", true); |
| 514 |
|
| 515 |
// Allow time for href to load, pane to expand, and resize to be called on children |
| 516 |
tp.onLoadDeferred.then(d.getTestCallback(function(){ |
| 517 |
// Check that resize() done on children |
| 518 |
doh.t(layoutResizes["ctpHmcBorderContainer"], "got resize event for BC"); |
| 519 |
doh.t(layoutResizes["ctpHmcTabContainer"], "got resize event for TC"); |
| 520 |
doh.is(0, layoutResizes["ctpHmcBorderContainer"][0].length, "no size specified for BC") |
| 521 |
})); |
| 522 |
|
| 523 |
return d; |
| 524 |
} |
| 525 |
}, |
| 526 |
|
| 527 |
{ |
| 528 |
name: "initially closed, multiple children", |
| 529 |
timeout: 2000, |
| 530 |
runTest: function(){ |
| 531 |
var d = new doh.Deferred(); |
| 532 |
|
| 533 |
doh.f(registry.byId("ctpMc_child1")._resized, "resize event for child1 deferred"); |
| 534 |
doh.f(registry.byId("ctpMc_child2")._resized, "resize event for child2 deferred"); |
| 535 |
|
| 536 |
var tp = registry.byId("ctpMc"); |
| 537 |
tp.set("open", true); |
| 538 |
|
| 539 |
// Allow time for pane to expand, and resize to be called on children |
| 540 |
setTimeout(d.getTestCallback(function(){ |
| 541 |
// Check that resize() done on children |
| 542 |
doh.t(registry.byId("ctpMc_child1")._resized, "got resize event for child1"); |
| 543 |
doh.t(registry.byId("ctpMc_child2")._resized, "got resize event for child2"); |
| 544 |
}), 750); |
| 545 |
|
| 546 |
return d; |
| 547 |
} |
| 548 |
} |
| 549 |
]); |
| 550 |
|
| 551 |
// Make sure that Dialog loads it's href when shown, and also that |
| 552 |
// it calls resize on its children when shown (since that's the contract |
| 553 |
// for layout widgets, and ContentPane is acting as a layout widget). |
| 554 |
doh.register("Dialog", [ |
| 555 |
{ |
| 556 |
name: "href multiple children", |
| 557 |
timeout: 10000, |
| 558 |
runTest: function(){ |
| 559 |
var d = new doh.Deferred(); |
| 560 |
|
| 561 |
doh.f(loadEvents["dlgHmc"], "dlgHmc load deferred until open"); |
| 562 |
|
| 563 |
var dlg = registry.byId("dlgHmc"); |
| 564 |
dlg.show(); |
| 565 |
|
| 566 |
// Allow time for href to load, pane to expand, and resize to be called on children |
| 567 |
dlg.onLoadDeferred.then(d.getTestCallback(function(){ |
| 568 |
// Check that href loaded |
| 569 |
doh.is(1, loadEvents["dlgHmc"], "dlgHmc loaded when expanded"); |
| 570 |
|
| 571 |
// Check that resize() done on children |
| 572 |
doh.t(layoutResizes["dlgHmcBorderContainer"], "got resize event for BC"); |
| 573 |
doh.t(layoutResizes["dlgHmcTabContainer"], "got resize event for TC"); |
| 574 |
doh.is(0, layoutResizes["dlgHmcBorderContainer"][0].length, "no size specified for BC") |
| 575 |
})); |
| 576 |
|
| 577 |
return d; |
| 578 |
}, |
| 579 |
tearDown: function(){ |
| 580 |
// Note: this currently triggers an CancelError to the console; |
| 581 |
// we are apparently canceling a Deferred that has already been resolved. |
| 582 |
var dlg = registry.byId("dlgHmc"); |
| 583 |
dlg.hide(); |
| 584 |
} |
| 585 |
}, |
| 586 |
|
| 587 |
{ |
| 588 |
name: "multiple inlined children", |
| 589 |
timeout: 2000, |
| 590 |
runTest: function(){ |
| 591 |
var d = new doh.Deferred(); |
| 592 |
|
| 593 |
doh.f(registry.byId("dlgMc_child1")._resized, "resize event for child1 deferred"); |
| 594 |
doh.f(registry.byId("dlgMc_child2")._resized, "resize event for child2 deferred"); |
| 595 |
|
| 596 |
var dlg = registry.byId("dlgMc"); |
| 597 |
dlg.show(); |
| 598 |
|
| 599 |
// Allow time for pane to expand, and resize to be called on children |
| 600 |
setTimeout(d.getTestCallback(function(){ |
| 601 |
// Check that resize() done on children |
| 602 |
doh.t(registry.byId("dlgMc_child1")._resized, "got resize event for child1"); |
| 603 |
doh.t(registry.byId("dlgMc_child2")._resized, "got resize event for child2"); |
| 604 |
}), 750); |
| 605 |
|
| 606 |
return d; |
| 607 |
}, |
| 608 |
tearDown: function(){ |
| 609 |
var dlg = registry.byId("dlgMc"); |
| 610 |
dlg.hide(); |
| 611 |
} |
| 612 |
} |
| 613 |
]); |
| 614 |
|
| 615 |
// Test that resizing a TabContainer doesn't reload href (when refreshOnShow=true), bug #8197 |
| 616 |
doh.register("TabContainer resize/reload tests", [ |
| 617 |
{ |
| 618 |
name: "initial conditions", |
| 619 |
timeout: 10000, |
| 620 |
runTest: function(){ |
| 621 |
// Wait for load events to occur (after fetching URL's) |
| 622 |
return registry.byId("reloadTC_pane1").onLoadDeferred; |
| 623 |
} |
| 624 |
}, |
| 625 |
{ |
| 626 |
name: "reload on reshow", |
| 627 |
timeout: 10000, |
| 628 |
runTest: function(){ |
| 629 |
var d = new doh.Deferred(); |
| 630 |
var reloadTC = registry.byId("reloadTC"), |
| 631 |
pane1 = registry.byId("reloadTC_pane1"), |
| 632 |
pane2 = registry.byId("reloadTC_pane2"); |
| 633 |
|
| 634 |
var originalPane1OnLoadDeferred = pane1.onLoadDeferred; |
| 635 |
|
| 636 |
reloadTC.selectChild(pane2); |
| 637 |
reloadTC.selectChild(pane1); |
| 638 |
|
| 639 |
doh.isNot(originalPane1OnLoadDeferred, pane1.onLoadDeferred, |
| 640 |
"selecting pane1 again created new onLoadDeferred"); |
| 641 |
|
| 642 |
return pane1.onLoadDeferred; |
| 643 |
} |
| 644 |
}, |
| 645 |
{ |
| 646 |
name: "no reload on TabContainer resize", |
| 647 |
timeout: 10000, |
| 648 |
runTest: function(){ |
| 649 |
var d = new doh.Deferred(); |
| 650 |
|
| 651 |
registry.byId("reloadTC").resize({h: 300, w: 300}); |
| 652 |
setTimeout(d.getTestCallback(function(){ |
| 653 |
doh.is(2, loadEvents.reloadTC_pane1, "pane1 not loaded again"); |
| 654 |
}), 750); |
| 655 |
|
| 656 |
return d; |
| 657 |
} |
| 658 |
} |
| 659 |
]); |
| 660 |
|
| 661 |
doh.run(); |
| 662 |
}); |
| 663 |
|
| 664 |
</script> |
| 665 |
</head> |
| 666 |
<body role="main"> |
| 667 |
<h1>dijit/layout/ContentPane layout related DOH test</h1> |
| 668 |
|
| 669 |
<p> |
| 670 |
Tests ContentPane in it's role as a layout widget, including as child of another layout widgets (especially TabContainer). |
| 671 |
</p> |
| 672 |
|
| 673 |
<h2>Tests that href gets loaded when ContentPane is first made visible</h2> |
| 674 |
<div id="outerTC" data-dojo-type="dijit/layout/TabContainer" data-dojo-props='style:"width: 880px; height: 200px;","aria-label":"outerTC"'> |
| 675 |
<div id="pane1" data-dojo-type="dijit/layout/ContentPane" data-dojo-props='href:"doc0.html", title:"Initially Selected", onLoad:myOnLoad'> |
| 676 |
initially selected pane |
| 677 |
</div> |
| 678 |
<div id="pane2" data-dojo-type="dijit/layout/ContentPane" data-dojo-props='href:"doc1.html", title:"Initially Hidden", onLoad:myOnLoad'> |
| 679 |
unselected pane |
| 680 |
</div> |
| 681 |
<div id="innerTC" data-dojo-type="dijit/layout/TabContainer" data-dojo-props='nested:true, title:"Nested TabContainer"'> |
| 682 |
<div id="innerPane1" data-dojo-type="dijit/layout/ContentPane" data-dojo-props='href:"doc0.html", title:"Initially Selected", onLoad:myOnLoad'> |
| 683 |
initially selected inner pane |
| 684 |
</div> |
| 685 |
<div id="innerPane2" data-dojo-type="dijit/layout/ContentPane" data-dojo-props='href:"doc1.html", title:"Initially Hidden", onLoad:myOnLoad'> |
| 686 |
unselected pane |
| 687 |
</div> |
| 688 |
</div> |
| 689 |
<div id="bc" data-dojo-type="dijit/layout/BorderContainer" data-dojo-props='title:"BorderContainer"'> |
| 690 |
<div id="bcPane1" data-dojo-type="dijit/layout/ContentPane" data-dojo-props='href:"doc0.html", region:"left", style:"width: 200px;", onLoad:myOnLoad'> |
| 691 |
left pane |
| 692 |
</div> |
| 693 |
<div id="bcPane2" data-dojo-type="dijit/layout/ContentPane" data-dojo-props='href:"doc1.html", region:"center", onLoad:myOnLoad'> |
| 694 |
center pane |
| 695 |
|
| 696 |
|
| 697 |
|
| 698 |
<div id="bcResizable1" data-dojo-type="ResizableWidget" ></div> |
| 699 |
<div id="bcResizable2" data-dojo-type="ResizableWidget" ></div> |
| 700 |
</div> |
| 701 |
</div> |
| 702 |
</div> |
| 703 |
|
| 704 |
<h2>Tests for resizing in a layout container hierarchy</h2> |
| 705 |
<div id="resizeTC" data-dojo-type="dijit/layout/TabContainer" data-dojo-props='style:"width: 880px; height: 200px;","aria-label":"resizeTC"'> |
| 706 |
<div id="resizePane1" data-dojo-type="dijit/layout/ContentPane" data-dojo-props='title:"Initially Selected", onLoad:myOnLoad'> |
| 707 |
initially selected pane |
| 708 |
</div> |
| 709 |
<div id="singleChildPane" data-dojo-type="dijit/layout/ContentPane" data-dojo-props='title:"Single ResizableChild", onLoad:myOnLoad'> |
| 710 |
<div id="singleChildResizable" data-dojo-type="ResizableWidget" ></div> |
| 711 |
</div> |
| 712 |
<div id="multipleChildPanes" data-dojo-type="dijit/layout/ContentPane" data-dojo-props='title:"Multiple ResizableChild", onLoad:myOnLoad'> |
| 713 |
<div id="multipleChildResizable1" data-dojo-type="ResizableWidget" ></div> |
| 714 |
<div style="border: groove blue medium;"> |
| 715 |
<span>hide the second widget to see if ContentPane can still find it</span> |
| 716 |
<div id="multipleChildResizable2" data-dojo-type="ResizableWidget" ></div> |
| 717 |
<span>ending text</span> |
| 718 |
</div> |
| 719 |
</div> |
| 720 |
<div id="multipleResizableInForm" data-dojo-type="dijit/layout/ContentPane" data-dojo-props='title:"Multiple resizable in form", onLoad:myOnLoad'> |
| 721 |
<div data-dojo-type="dijit/form/Form"> |
| 722 |
<div id="resizableInForm1" data-dojo-type="ResizableWidget" ></div> |
| 723 |
<div id="resizableInForm2" data-dojo-type="ResizableWidget" ></div> |
| 724 |
</div> |
| 725 |
</div> |
| 726 |
<div id="singleResizableInForm" data-dojo-type="dijit/layout/ContentPane" data-dojo-props='title:"Single resizable in form", onLoad:myOnLoad'> |
| 727 |
<div data-dojo-type="dijit/form/Form"> |
| 728 |
<div id="resizableInForm0" data-dojo-type="ResizableWidget" ></div> |
| 729 |
</div> |
| 730 |
</div> |
| 731 |
<div id="singleChildHref" data-dojo-type="dijit/layout/ContentPane" data-dojo-props='title:"Href Single Child", |
| 732 |
href:"borderContainer.php?id=singleChildHref", onLoad:myOnLoad'></div> |
| 733 |
<div id="multipleChildHref" data-dojo-type="dijit/layout/ContentPane" data-dojo-props='title:"Href Multiple Children", |
| 734 |
href:"multipleLayoutWidgets.php?id=multipleChildHref", onLoad:myOnLoad'></div> |
| 735 |
</div> |
| 736 |
|
| 737 |
|
| 738 |
<h2>Size on Form, single nested layout widget</h2> |
| 739 |
<form data-dojo-type="dijit/form/Form" style="height:100px; width: 100px; border: medium inset gray; padding: 10px;" id="fss"> |
| 740 |
<div data-dojo-type="ResizableWidget" id="fssc"></div> |
| 741 |
</form> |
| 742 |
<form data-dojo-type="dijit/form/Form" style="height:100px; width: 100px; border: medium inset gray; padding: 10px;" id="fss2"> |
| 743 |
|
| 744 |
<div id="fss2_rc" data-dojo-type="ResizableWidget">resizable</div> |
| 745 |
<div id="fss2_ic" data-dojo-type="dojo/store/Memory"></div> |
| 746 |
</form> |
| 747 |
<h2>Size on Form, multiple nested widgets</h2> |
| 748 |
|
| 749 |
<form data-dojo-type="dijit/form/Form" style="height:250px; width: 150px; border: medium inset gray; padding: 10px;" id="fsm"> |
| 750 |
<div data-dojo-type="ResizableWidget" style="width: 100px; height: 100px; border: 1px solid black;" id="fsmc1"> |
| 751 |
child #1 (100x100) |
| 752 |
</div> |
| 753 |
<div data-dojo-type="ResizableWidget" style="width: 100px; height: 100px; border: 1px solid black;" id="fsmc2"> |
| 754 |
child #2 (100x100) |
| 755 |
</div> |
| 756 |
</form> |
| 757 |
<form data-dojo-type="dijit/form/Form" style="height:250px; width: 150px; border: medium inset gray; padding: 10px;" id="fsm2"> |
| 758 |
<div id="fsm2_vc" data-dojo-type="dijit/_WidgetBase">visible</div> |
| 759 |
<div id="fsm2_rc" data-dojo-type="ResizableWidget">resizable</div> |
| 760 |
</form> |
| 761 |
|
| 762 |
<h2>No size on Form, single nested layout widgets</h2> |
| 763 |
<form data-dojo-type="dijit/form/Form" style="border: medium inset gray; padding: 10px;" data-dojo-props="doLayout: false" id="fns"> |
| 764 |
<div data-dojo-type="ResizableWidget" style="height:200px; width: 400px;" id="fnsc"> |
| 765 |
</div> |
| 766 |
</form> |
| 767 |
|
| 768 |
<h2>No size on Form, multiple nested layout widget</h2> |
| 769 |
<form data-dojo-type="dijit/form/Form" style="border: medium inset gray; padding: 10px;" id="fnm"> |
| 770 |
<div data-dojo-type="ResizableWidget" style="width: 100px; height: 100px; border: 1px solid black;" id="fnmc1"> |
| 771 |
child #1 (100x100) |
| 772 |
</div> |
| 773 |
<div data-dojo-type="ResizableWidget" style="width: 100px; height: 100px; border: 1px solid black;" id="fnmc2"> |
| 774 |
child #2 (100x100) |
| 775 |
</div> |
| 776 |
</form> |
| 777 |
|
| 778 |
<h2>Tests that ContentPane resize doesn't trigger reload</h2> |
| 779 |
<div id="reloadTC" data-dojo-type="dijit/layout/TabContainer" data-dojo-props='style:"width: 880px; height: 200px;","aria-label":"outerTC"'> |
| 780 |
<div id="reloadTC_pane1" data-dojo-type="dijit/layout/ContentPane" data-dojo-props='href:"doc0.html", title:"Initially Selected", onLoad:myOnLoad, refreshOnShow:true'> |
| 781 |
initially selected pane |
| 782 |
</div> |
| 783 |
<div id="reloadTC_pane2" data-dojo-type="dijit/layout/ContentPane" data-dojo-props='href:"doc1.html", title:"Initially Hidden", onLoad:myOnLoad'> |
| 784 |
unselected pane |
| 785 |
</div> |
| 786 |
</div> |
| 787 |
|
| 788 |
<h2>Test the ContentPane loads href and resizes children (as per it's contract a layout widget) |
| 789 |
when it's not a child of a layout container itself</h2> |
| 790 |
<div id="ctpHsc" data-dojo-type="dijit/TitlePane" data-dojo-props='title:"Closed TitlePane Href Single Child", open:false, |
| 791 |
href:"borderContainer.php?id=ctpHsc&sized=true", onLoad:myOnLoad'></div> |
| 792 |
<br><br> |
| 793 |
|
| 794 |
<div id="ctpHmc" data-dojo-type="dijit/TitlePane" data-dojo-props='title:"Closed TitlePane Href Multiple Children", open:false, |
| 795 |
href:"multipleLayoutWidgets.php?id=ctpHmc", onLoad:myOnLoad'></div> |
| 796 |
<br><br> |
| 797 |
|
| 798 |
<div id="otpHsc" data-dojo-type="dijit/TitlePane" data-dojo-props='title:"Opened TitlePane Href Single Child", |
| 799 |
href:"borderContainer.php?id=otpHsc&sized=true", onLoad:myOnLoad'></div> |
| 800 |
<br><br> |
| 801 |
|
| 802 |
<div id="otpHmc" data-dojo-type="dijit/TitlePane" data-dojo-props='title:"Opened TitlePane Href Multiple Children", |
| 803 |
href:"multipleLayoutWidgets.php?id=otpHmc", onLoad:myOnLoad'></div> |
| 804 |
<br><br> |
| 805 |
|
| 806 |
<div id="otpMc" data-dojo-type="dijit/TitlePane" data-dojo-props='title:"Opened TitlePane Multiple Children"'> |
| 807 |
|
| 808 |
<div id="otpMc_child1" data-dojo-type="ResizableWidget" ></div> |
| 809 |
<div id="otpMc_child2" data-dojo-type="ResizableWidget" ></div> |
| 810 |
</div> |
| 811 |
<br><br> |
| 812 |
|
| 813 |
<div id="ctpMc" data-dojo-type="dijit/TitlePane" data-dojo-props='title:"Closed TitlePane Multiple Children", open:false'> |
| 814 |
|
| 815 |
<div id="ctpMc_child1" data-dojo-type="ResizableWidget" ></div> |
| 816 |
<div id="ctpMc_child2" data-dojo-type="ResizableWidget" ></div> |
| 817 |
</div> |
| 818 |
<br><br> |
| 819 |
|
| 820 |
<div id="dlgHmc" data-dojo-type="dijit/Dialog" data-dojo-props='title:"Dialog Href Multiple Children", |
| 821 |
href:"multipleLayoutWidgets.php?id=dlgHmc", onLoad:myOnLoad'></div> |
| 822 |
|
| 823 |
<div id="dlgMc" data-dojo-type="dijit/Dialog" data-dojo-props='title:"Dialog Multiple Children"'> |
| 824 |
|
| 825 |
<div id="dlgMc_child1" data-dojo-type="ResizableWidget" ></div> |
| 826 |
<div id="dlgMc_child2" data-dojo-type="ResizableWidget" ></div> |
| 827 |
</div> |
| 828 |
|
| 829 |
</body> |
| 830 |
</html> |