| 1 | <!DOCTYPE html> |
| 2 | <html lang="en"> |
| 3 | <head> |
| 4 | <meta http-equiv="Content-type" content="text/html; charset=utf-8"> |
| 5 | <title>ContentPane Remote Loading Test</title> |
| 6 | |
| 7 | <script src="../boilerplate.js"></script> |
| 8 | |
| 9 | <script type="text/javascript"> |
| 10 | require([ |
| 11 | "doh/runner", |
| 12 | "dojo/_base/array", |
| 13 | "dojo/aspect", |
| 14 | "dojo/_base/declare", |
| 15 | "dojo/dom", |
| 16 | "dojo/dom-class", |
| 17 | "dojo/_base/lang", |
| 18 | "dojo/parser", |
| 19 | "dojo/request", |
| 20 | "dojo/when", |
| 21 | "dijit/registry", |
| 22 | "dijit/_WidgetBase", |
| 23 | "dijit/_TemplatedMixin", |
| 24 | "dijit/Tooltip", |
| 25 | "dijit/TooltipDialog", |
| 26 | "dijit/form/Button", |
| 27 | "dijit/form/DropDownButton", |
| 28 | "dijit/layout/ContentPane", |
| 29 | "dijit/layout/StackContainer", |
| 30 | "dijit/layout/TabContainer", |
| 31 | "dijit/layout/AccordionContainer", |
| 32 | "dijit/tests/helpers", |
| 33 | "dojo/domReady!" |
| 34 | ], function(doh, array, aspect, declare, dom, domClass, lang, parser, request, when, |
| 35 | registry, _WidgetBase, _TemplatedMixin, Tooltip, TooltipDialog, Button, DropDownButton, |
| 36 | ContentPane, StackContainer, TabContainer, AccordionContainer, helpers){ |
| 37 | |
| 38 | var tabCounter; |
| 39 | testClose = function(pane, tab){ |
| 40 | // remove html from title |
| 41 | var title = lang.trim(tab.title.replace(/<\/?[a-z][a-z0-9]*[^>]*>/ig, "")); |
| 42 | return confirm("Please confirm that you want tab "+title+" closed"); |
| 43 | }; |
| 44 | |
| 45 | |
| 46 | createTab = function(){ |
| 47 | if(!tabCounter){ tabCounter = 3; } |
| 48 | |
| 49 | var title = '<img src="../images/plus.gif" style="background-color:#95B7D3;"/> Tab ' +(++tabCounter); |
| 50 | var refreshOnShow = !!(tabCounter % 2); |
| 51 | |
| 52 | var newTab = new ContentPane({ |
| 53 | id: "ttab" + tabCounter, |
| 54 | title: title + (refreshOnShow ? ' <i>refreshOnShow</i>': ''), |
| 55 | closable:true, |
| 56 | refreshOnShow: refreshOnShow, |
| 57 | href: 'getResponse.php?delay=1000&messId='+tabCounter |
| 58 | +"&message="+encodeURI("<h1>Programmatically created Tab "+tabCounter+"</h1>") |
| 59 | }, document.createElement('div')); |
| 60 | |
| 61 | registry.byId('ttabs').addChild(newTab); |
| 62 | |
| 63 | newTab.startup(); |
| 64 | }; |
| 65 | |
| 66 | // create a do nothing, only for test widget |
| 67 | declare("TestWidget", |
| 68 | [_WidgetBase, _TemplatedMixin], { |
| 69 | templateString: "<span class='dijitTestWidget'></span>" |
| 70 | }); |
| 71 | |
| 72 | |
| 73 | doh.register("parse", function parse(){ |
| 74 | console.log("parse"); |
| 75 | return parser.parse(); |
| 76 | }); |
| 77 | |
| 78 | var cp, cp1; |
| 79 | |
| 80 | doh.register("ContentPane", [ |
| 81 | function create(){ |
| 82 | cp = new ContentPane({}, dom.byId("cp")); |
| 83 | |
| 84 | cp1 = new declare(ContentPane, { |
| 85 | preprocessContent: function(content){ |
| 86 | if(typeof content === "string"){ |
| 87 | // return a reversed string |
| 88 | var reverse = ""; |
| 89 | for(var i = content.length - 1; i >= 0; i--){ |
| 90 | reverse += content[i]; |
| 91 | } |
| 92 | return reverse; |
| 93 | }else{ |
| 94 | // wrap the DocumentFragment in a div |
| 95 | var frag = document.createDocumentFragment(); |
| 96 | var div = document.createElement("div"); |
| 97 | div.appendChild(content); |
| 98 | frag.appendChild(div); |
| 99 | return frag; |
| 100 | } |
| 101 | } |
| 102 | })({}, dom.byId("cp1")); |
| 103 | }, |
| 104 | |
| 105 | { |
| 106 | name: "setHref_loading", |
| 107 | timeout: 10000, |
| 108 | setUp: function(t){ |
| 109 | }, |
| 110 | runTest: function(t){ |
| 111 | var d = new doh.Deferred(); |
| 112 | |
| 113 | cp.set('href', 'getResponse.php?messId=1').then(d.getTestCallback(function(){ |
| 114 | doh.is(1, _WidgetBase.prototype.getChildren.call(cp).length); |
| 115 | })); |
| 116 | return d; |
| 117 | } |
| 118 | }, |
| 119 | { |
| 120 | name: "setHref_then_cancel", |
| 121 | timeout: 2800, |
| 122 | setUp: function(t){ |
| 123 | cp.set("content", "");// clear previous |
| 124 | }, |
| 125 | runTest: function(t){ |
| 126 | var msg = "This should NEVER be seen!"; |
| 127 | cp.set('href', 'getResponse.php?delay=1000&message='+encodeURI(msg)); |
| 128 | var d = new t.Deferred(); |
| 129 | setTimeout(d.getTestCallback( |
| 130 | function(){ |
| 131 | doh.f(cp.domNode.innerHTML == msg); |
| 132 | } |
| 133 | ), 2500); |
| 134 | |
| 135 | cp.cancel(); |
| 136 | |
| 137 | return d; |
| 138 | } |
| 139 | }, |
| 140 | { |
| 141 | // test that setHref cancels a inflight setHref |
| 142 | name: "setHref_cancels_previous_setHref", |
| 143 | timeout: 10000, |
| 144 | setUp: function(t){ |
| 145 | cp.set("content", ""); |
| 146 | }, |
| 147 | runTest: function(t){ |
| 148 | var d = new t.Deferred(); |
| 149 | |
| 150 | var msgCanceled = "This should be canceled"; |
| 151 | cp.set('href', "getResponse.php?delay=1000&message="+encodeURI(msgCanceled)); |
| 152 | |
| 153 | setTimeout(d.getTestErrback(function(){ |
| 154 | var msg = "This message should win over the previous"; |
| 155 | cp.set('href', "getResponse.php?message="+encodeURI(msg)); |
| 156 | |
| 157 | setTimeout(d.getTestCallback( |
| 158 | function(){ |
| 159 | doh.is(msg, cp.domNode.innerHTML); |
| 160 | } |
| 161 | ), 1600); |
| 162 | }), 900); |
| 163 | |
| 164 | return d; |
| 165 | } |
| 166 | }, |
| 167 | { |
| 168 | name: "setContent_cancels_setHref", |
| 169 | timeout: 2800, |
| 170 | setUp: function(t){ |
| 171 | cp.set("content", ""); |
| 172 | }, |
| 173 | runTest: function(t){ |
| 174 | cp.on("unload", function(){ |
| 175 | console.log("cp unload of: " + cp.get('content')); |
| 176 | }); |
| 177 | cp.on("load", function(){ |
| 178 | console.log("cp load of: " + cp.get('content')); |
| 179 | }); |
| 180 | var msgCanceled = "This message be canceled"; |
| 181 | cp.set('href', "getResponse.php?delay=1000&message="+encodeURI(msgCanceled)); |
| 182 | |
| 183 | var msg = "This message should win over (ie, cancel) the inflight one"; |
| 184 | setTimeout(function(){ |
| 185 | cp.set("content", msg); |
| 186 | }, 500); |
| 187 | |
| 188 | var d = new t.Deferred(); |
| 189 | setTimeout(d.getTestCallback( |
| 190 | function(){ |
| 191 | doh.is(msg, cp.domNode.innerHTML); |
| 192 | } |
| 193 | ), 2500); |
| 194 | return d; |
| 195 | } |
| 196 | }, |
| 197 | { |
| 198 | name: "refresh", |
| 199 | timeout: 1900, |
| 200 | setUp: function(t){ |
| 201 | cp.set('href', "getResponse.php?message="+encodeURI('initial load')); |
| 202 | }, |
| 203 | runTest: function(t){ |
| 204 | var d = new doh.Deferred(); |
| 205 | |
| 206 | setTimeout(d.getTestErrback(function(){ |
| 207 | var msg = 'refreshed load'; |
| 208 | cp.href = "getResponse.php?message="+encodeURI(msg); |
| 209 | cp.refresh().then(d.getTestCallback(function(){ |
| 210 | doh.is(msg, cp.domNode.innerHTML); |
| 211 | })); |
| 212 | }), 100); |
| 213 | |
| 214 | return d; |
| 215 | } |
| 216 | }, |
| 217 | { |
| 218 | // Test isLoaded attribute lifecycle and that onLoad/onUnload callbacks |
| 219 | // are called at the right times |
| 220 | name: "isLoaded", |
| 221 | |
| 222 | timeout: 10000, |
| 223 | setUp: function(t){ |
| 224 | cp.set("content", ""); |
| 225 | }, |
| 226 | runTest: function(t){ |
| 227 | doh.t(cp.isLoaded, "cp initially loaded"); |
| 228 | |
| 229 | // Setup handlers to track when onUnload and onLoad are called, |
| 230 | // including tracking if they get called repeatedly (they shouldn't) |
| 231 | var history = ""; |
| 232 | var handles = [ |
| 233 | cp.on("unload", function(){ history += "unloaded"}), |
| 234 | cp.on("load", function(){ history += " and reloaded"}) |
| 235 | ]; |
| 236 | |
| 237 | cp.set('href', "getResponse.php?delay=300&message=test"); |
| 238 | |
| 239 | doh.f(cp.isLoaded, "immediately after href set, cp isLoaded == false"); |
| 240 | doh.is("unloaded", history); |
| 241 | |
| 242 | var ilObj = {}; // a object to get a reference instead of copy |
| 243 | |
| 244 | // probe after 200ms |
| 245 | setTimeout(function(){ |
| 246 | ilObj.probed = cp.isLoaded; |
| 247 | }, 200); |
| 248 | |
| 249 | var d = new t.Deferred(); |
| 250 | handles.push(aspect.after(cp, "_setContent", d.getTestCallback(function(){ |
| 251 | doh.f(ilObj.probed, "200ms after href set, cp was not loaded"); |
| 252 | doh.t(cp.isLoaded, "eventually, cp was loaded"); |
| 253 | doh.is("unloaded and reloaded", history); |
| 254 | |
| 255 | array.forEach(handles, function(handle){ |
| 256 | handle.remove(); |
| 257 | }); |
| 258 | }), true)); |
| 259 | return d; |
| 260 | } |
| 261 | }, |
| 262 | { |
| 263 | // test that we don't load a response if we are hidden |
| 264 | name: "wait_with_load_when_domNode_hidden", |
| 265 | timeout: 1800, |
| 266 | setUp: function(t){ |
| 267 | cp.domNode.style.display = 'none'; |
| 268 | cp.set("content", ""); |
| 269 | }, |
| 270 | runTest: function(t){ |
| 271 | cp._msg = "This text should not be loaded until after widget is shown"; |
| 272 | cp.set('href', "getResponse.php?message="+encodeURI(cp._msg)); |
| 273 | var d = new t.Deferred(); |
| 274 | setTimeout(d.getTestCallback( |
| 275 | function(){ |
| 276 | doh.isNot(cp._msg, cp.domNode.innerHTML); |
| 277 | } |
| 278 | ), 1500); |
| 279 | return d; |
| 280 | }, |
| 281 | tearDown: function(t){ |
| 282 | cp.domNode.style.display = ""; |
| 283 | } |
| 284 | }, |
| 285 | { |
| 286 | name: "onDownloadError", |
| 287 | timeout: 1800, |
| 288 | setUp: function(t){ |
| 289 | cp.set("content", ""); |
| 290 | }, |
| 291 | runTest: function(t){ |
| 292 | var msg = "Error downloading modified message"; |
| 293 | orig = cp.onDownloadError; |
| 294 | |
| 295 | cp.onDownloadError = function(){ |
| 296 | return msg; |
| 297 | }; |
| 298 | |
| 299 | var d = new doh.Deferred(); |
| 300 | |
| 301 | evtHandle = cp.on("downloaderror", d.getTestErrback(function(e){ |
| 302 | doh.t(e, "onDownloadError got event argument on invokation"); |
| 303 | setTimeout(d.getTestCallback(function(){ |
| 304 | doh.is(msg, cp.domNode.innerHTML, "custom errortext set"); |
| 305 | }), 1); |
| 306 | })); |
| 307 | |
| 308 | // test onDownloadError |
| 309 | cp.set('href', 'nonexistent'); |
| 310 | |
| 311 | return d; |
| 312 | }, |
| 313 | tearDown: function(){ |
| 314 | evtHandle.remove(); |
| 315 | cp.onDownloadError = orig; |
| 316 | } |
| 317 | }, |
| 318 | |
| 319 | // Test that setting an href calls onDownloadStart followed by onDownloadEnd, |
| 320 | // and also setting of custom download message instead of "Loading..." |
| 321 | { |
| 322 | name: "onDownloadStart|End", |
| 323 | timeout: 5000, |
| 324 | setUp:function(t){ |
| 325 | cp.set("content", ""); |
| 326 | }, |
| 327 | runTest:function(t){ |
| 328 | var d = new doh.Deferred(); |
| 329 | |
| 330 | // set custom message |
| 331 | origStart = cp.onDownloadStart; |
| 332 | var msg = "custom downloadstart message"; |
| 333 | cp.onDownloadStart = function(){ return msg; }; |
| 334 | |
| 335 | startHandle = cp.on("downloadstart", d.getTestErrback(function(){ |
| 336 | setTimeout(d.getTestErrback(function(){ |
| 337 | // check that custom message was set |
| 338 | doh.is(msg, cp.containerNode.innerHTML, "custom download message was set"); |
| 339 | |
| 340 | // and then wait for the download to complete |
| 341 | endHandle = cp.on("downloadend", d.getTestCallback(function(){ |
| 342 | // if this gets called (before the test timeout) then test succeeded |
| 343 | })); |
| 344 | }), 1); |
| 345 | })); |
| 346 | cp.set('href', 'getResponse.php?delay=400&messId=3'); |
| 347 | |
| 348 | return d; |
| 349 | }, |
| 350 | tearDown: function(){ |
| 351 | cp.onDownloadStart = origStart; |
| 352 | startHandle.remove(); |
| 353 | endHandle.remove(); |
| 354 | } |
| 355 | }, |
| 356 | |
| 357 | // Test that setting an href calls onUnload followed by onLoad |
| 358 | { |
| 359 | name: "onLoad|onUnload", |
| 360 | timeout: 5000, |
| 361 | setUp:function(t){ |
| 362 | cp.set("content", ""); |
| 363 | }, |
| 364 | runTest:function(t){ |
| 365 | var d = new doh.Deferred(); |
| 366 | |
| 367 | loadHandle = cp.on("unload", d.getTestErrback(function(){ |
| 368 | unloadHandle = cp.on("load", d.getTestCallback(function(){ |
| 369 | // if this gets called (before the test timeout) then test succeeded |
| 370 | })); |
| 371 | })); |
| 372 | cp.set('href', 'getResponse.php?delay=400&messId=2'); |
| 373 | |
| 374 | return d; |
| 375 | }, |
| 376 | tearDown: function(){ |
| 377 | loadHandle.remove(); |
| 378 | unloadHandle.remove(); |
| 379 | } |
| 380 | }, |
| 381 | |
| 382 | // Test that preprocessContent returns as expected when setting |
| 383 | // content as a string |
| 384 | { |
| 385 | name: "preprocessContent.string", |
| 386 | timeout: 5000, |
| 387 | setUp:function(t){ |
| 388 | cp1.set("content", "foo"); |
| 389 | }, |
| 390 | runTest:function(t){ |
| 391 | doh.is("oof", cp1.get("content"), "preprocessContent(string)"); |
| 392 | } |
| 393 | }, |
| 394 | |
| 395 | { |
| 396 | name: "preprocessContent.DocumentFragment", |
| 397 | timeout: 5000, |
| 398 | setUp:function(t){ |
| 399 | var docFrag = document.createDocumentFragment(); |
| 400 | var span = document.createElement("span"); |
| 401 | docFrag.appendChild(span); |
| 402 | cp1.set("content", docFrag); |
| 403 | }, |
| 404 | runTest:function(t){ |
| 405 | doh.is("<div><span></span></div>", cp1.get("content").toLowerCase(), |
| 406 | "preprocessContent(DocumentFragment)"); |
| 407 | } |
| 408 | } |
| 409 | |
| 410 | ]); |
| 411 | |
| 412 | function selectChildAndTestLoad(/*String*/ parentId, /*String*/ childId, /*String*/ startOfExpectedContent){ |
| 413 | // summary: |
| 414 | // Test deferred load of child of StackContainer widget |
| 415 | |
| 416 | var d = new doh.Deferred(), |
| 417 | loadingContent, |
| 418 | child = registry.byId(childId), |
| 419 | contentNode = dom.byId(childId); |
| 420 | |
| 421 | child.ioMethod = function(args){ |
| 422 | loadingContent = helpers.innerText(contentNode); |
| 423 | delete child.ioMethod; |
| 424 | return request(args.url, args); |
| 425 | }; |
| 426 | |
| 427 | when(registry.byId(parentId).selectChild(child), function(){ |
| 428 | setTimeout(d.getTestCallback( |
| 429 | function(){ |
| 430 | doh.is(child.loadingMessage.replace(/<[^>]*>/g, ""), loadingContent, "loading message"); |
| 431 | var startOfActualContent = helpers.innerText(contentNode).substring(0, startOfExpectedContent.length); |
| 432 | doh.is(startOfExpectedContent, startOfActualContent, "expected content"); |
| 433 | } |
| 434 | ), 1); // return from handler, then test |
| 435 | }); |
| 436 | |
| 437 | return d; |
| 438 | } |
| 439 | |
| 440 | var st, // stack container |
| 441 | pane3, pane3UnloadCnt=0, pane3LoadCnt=0, // second child of stack container (initially hidden) |
| 442 | tmp; |
| 443 | |
| 444 | doh.register("ContentPane in StackContainer", [ |
| 445 | { |
| 446 | // TODO: this test should be moved to registerGroup setUp now that #3504 is fixed |
| 447 | // We actually don't need to test anything here, just setUp |
| 448 | name: "setUp_StackContainer", |
| 449 | setUp:function(t){ |
| 450 | // create a StackContainer |
| 451 | st = dom.byId('stackcontainer'); |
| 452 | domClass.add(st, 'box'); |
| 453 | st = new StackContainer({style: {height: "150px"}}, st); |
| 454 | |
| 455 | // the first child (by default) is the one that will |
| 456 | // be shown |
| 457 | st.addChild(new TestWidget()); |
| 458 | |
| 459 | // the second child *won't* be shown until selected |
| 460 | pane3 = new ContentPane({ |
| 461 | id:"sc_pane2", |
| 462 | href:'getResponse.php?delay=300&message=Loaded!', |
| 463 | preventCache: true, |
| 464 | onLoad: function(){ pane3LoadCnt++; }, |
| 465 | onUnload: function(){ pane3UnloadCnt++; } |
| 466 | }, document.createElement('div')); |
| 467 | st.addChild(pane3); |
| 468 | |
| 469 | // start the StackContainer; shouldn't cause ContentPane to load. |
| 470 | st.startup(); |
| 471 | }, |
| 472 | runTest:function(t){ |
| 473 | doh.t(st); |
| 474 | doh.is(2, st.getChildren().length); |
| 475 | } |
| 476 | }, |
| 477 | { |
| 478 | name: "preload_false_by_default", |
| 479 | runTest: function(t){ |
| 480 | doh.f(pane3.isLoaded); |
| 481 | doh.is('', pane3.domNode.innerHTML); |
| 482 | } |
| 483 | }, |
| 484 | { |
| 485 | name: "unload event not called initially", |
| 486 | runTest: function(t){ |
| 487 | doh.is(0, pane3UnloadCnt); |
| 488 | } |
| 489 | }, |
| 490 | { |
| 491 | name: "load event fired when pane is shown", |
| 492 | timeout: 10000, |
| 493 | runTest: function(t){ |
| 494 | doh.is(0, pane3LoadCnt, "onload hasn't been called yet"); |
| 495 | |
| 496 | var d = new doh.Deferred(); |
| 497 | |
| 498 | when(st.selectChild(pane3), function(){ |
| 499 | setTimeout(d.getTestCallback(function(){ |
| 500 | doh.t(pane3.isLoaded, "pane3.isLoaded"); |
| 501 | doh.is(1, pane3LoadCnt, "onload was called"); |
| 502 | doh.is('Loaded!', pane3.domNode.innerHTML); |
| 503 | doh.is(0, pane3UnloadCnt, |
| 504 | "unload shouldn't have been called b/c no initial contents (#2)"); |
| 505 | }), 1); |
| 506 | }); |
| 507 | |
| 508 | doh.is(0, pane3UnloadCnt, |
| 509 | "unload shouldn't have been called b/c no initial contents (#1)"); |
| 510 | |
| 511 | return d; |
| 512 | } |
| 513 | }, |
| 514 | { |
| 515 | name: "refreshOnShow parameter works", |
| 516 | timeout: 10000, |
| 517 | setUp: function(t){ |
| 518 | tmp = { |
| 519 | onUnload: function(){ this._unload_fired = 1; }, |
| 520 | onLoad: function(){ this._load_fired = 1; } |
| 521 | }; |
| 522 | tmp.unloadHandle = pane3.on("unload", lang.hitch(tmp, 'onUnload')); |
| 523 | tmp.loadHandle = pane3.on("load", lang.hitch(tmp, 'onLoad')); |
| 524 | |
| 525 | pane3.refreshOnShow = true; |
| 526 | }, |
| 527 | runTest: function(t){ |
| 528 | var d = new doh.Deferred(); |
| 529 | |
| 530 | // Show pane 3 again and see if events fire |
| 531 | st.back(); |
| 532 | st.forward().then(function(){ |
| 533 | setTimeout(d.getTestCallback(function(){ |
| 534 | doh.t(tmp._unload_fired, "unload was fired"); |
| 535 | doh.t(tmp._load_fired, "load was fired"); |
| 536 | doh.is('Loaded!', pane3.domNode.innerHTML); |
| 537 | }), 1); |
| 538 | }); |
| 539 | |
| 540 | return d; |
| 541 | }, |
| 542 | tearDown: function(){ |
| 543 | tmp.unloadHandle.remove(); |
| 544 | tmp.loadHandle.remove(); |
| 545 | pane3.refreshOnShow = pane3.constructor.prototype.refreshOnShow; |
| 546 | } |
| 547 | } |
| 548 | ]); |
| 549 | |
| 550 | doh.register("ContentPane in TabContainer", [ |
| 551 | { |
| 552 | name: "tab1InitialLoading", |
| 553 | timeout: 9000, |
| 554 | runTest: function(){ return selectChildAndTestLoad("ttabs", "ttab1", "IT WAS"); } |
| 555 | } |
| 556 | ]); |
| 557 | |
| 558 | doh.register("ContentPane in AccordionContainer", [ |
| 559 | { |
| 560 | name: "pane3InitialLoading", |
| 561 | timeout: 9000, |
| 562 | runTest: function(){ return selectChildAndTestLoad("ac", "ac_pane3", "There"); } |
| 563 | }, |
| 564 | { |
| 565 | name: "cpInitialLoading", |
| 566 | timeout: 9000, |
| 567 | runTest: function(){ return selectChildAndTestLoad("ac", "ac_pane2", "There"); } |
| 568 | }, |
| 569 | { |
| 570 | name: "pane3Refresh", |
| 571 | timeout: 5000, |
| 572 | runTest: function(t){ |
| 573 | var d = new doh.Deferred(), |
| 574 | wasLoading = false, |
| 575 | widget = registry.byId("ac_pane3"), |
| 576 | loadhandler = widget.on("downloadStart", function(){ |
| 577 | loadhandler.remove(); |
| 578 | wasLoading = true; |
| 579 | }), |
| 580 | showhandler = widget.on("show", function(){ |
| 581 | showhandler.remove(); |
| 582 | setTimeout(d.getTestCallback( |
| 583 | function(){ |
| 584 | doh.f(wasLoading, "should not have reloaded") |
| 585 | } |
| 586 | ), 1000); |
| 587 | }); |
| 588 | |
| 589 | registry.byId("ac").selectChild("ac_pane3"); |
| 590 | |
| 591 | return d; |
| 592 | } |
| 593 | }, |
| 594 | { |
| 595 | name: "cpRefresh", |
| 596 | timeout: 9000, |
| 597 | runTest: function(){ return selectChildAndTestLoad("ac", "ac_pane2", "There"); } |
| 598 | } |
| 599 | ]); |
| 600 | |
| 601 | doh.register("TooltipDialog", [ |
| 602 | // The preload=true TooltipDialog should already be loaded, or at least be loading, |
| 603 | // if it isn't already loading then this test will timeout. |
| 604 | { |
| 605 | name: "preload=true", |
| 606 | timeout: 5000, |
| 607 | runTest: function(t){ |
| 608 | var dlg = registry.byId("preloadTooltipDlg"); |
| 609 | if(!dlg.isLoaded){ |
| 610 | doh.t(dlg.onLoadDeferred, "onLoadDeferred exists"); |
| 611 | return dlg.onLoadDeferred; |
| 612 | } |
| 613 | } |
| 614 | }, |
| 615 | |
| 616 | // The preload=false TooltipDialog shouldn't load until opened. |
| 617 | { |
| 618 | name: "preload=false", |
| 619 | timeout: 5000, |
| 620 | runTest: function(){ |
| 621 | // Check that it isn't loaded yet |
| 622 | var dlg = registry.byId("noPreloadTooltipDlg"); |
| 623 | doh.f(dlg.isLoaded, "didn't load yet"); |
| 624 | |
| 625 | // Open the dialog and then return Deferred waiting for it to load. |
| 626 | // If it doesn't load then this test will get a timeout. |
| 627 | var btn = registry.byId("noPreloadTooltipDlgBtn"); |
| 628 | btn.openDropDown(); |
| 629 | doh.t(dlg.onLoadDeferred, "onLoadDeferred exists"); |
| 630 | return dlg.onLoadDeferred; |
| 631 | } |
| 632 | } |
| 633 | ]); |
| 634 | |
| 635 | doh.run(); |
| 636 | }); |
| 637 | </script> |
| 638 | </head> |
| 639 | <body class="claro" role="main"> |
| 640 | |
| 641 | <h1 class="testTitle">Dijit layout.ContentPane (delayed) remote tests</h1> |
| 642 | |
| 643 | <h2>Plain ContentPane</h2> |
| 644 | <div id='cp' class='box'></div> |
| 645 | |
| 646 | <h2>preprocessContent ContentPane</h2> |
| 647 | <div id='cp1' class='box'></div> |
| 648 | |
| 649 | <h2>StackContainer</h2> |
| 650 | <div id='stackcontainer'></div> |
| 651 | |
| 652 | <h2>TabContainer</h2> |
| 653 | <p>These tabs are made up of external content. Loading is delayed to make it easier to see if refreshOnShow and preload = 'false' is working.<br/> |
| 654 | The tabs also tests to insert html in the Tab title |
| 655 | </p> |
| 656 | |
| 657 | <div id="createTabButton" data-dojo-type='dijit/form/Button' data-dojo-props='onClick:function(){ createTab() }'>Create a Tab</div> |
| 658 | <div id="ttabs" data-dojo-type="dijit/layout/TabContainer" data-dojo-props='tabPosition:"top", style:"width: 100%; height: 20em;"'> |
| 659 | <div id="ttab1" data-dojo-type="dijit/layout/ContentPane" |
| 660 | data-dojo-props='href:"getResponse.php?messId=3&delay=1000", |
| 661 | closable:true' |
| 662 | title="Tab1"></div> |
| 663 | <div id="ttab2" data-dojo-type="dijit/layout/ContentPane" |
| 664 | data-dojo-props='href:"getResponse.php?messId=4&delay=1000", |
| 665 | refreshOnShow:true, title:"Tab 2 ", |
| 666 | selected:true, |
| 667 | closable:true' |
| 668 | title="refreshOnShow"></div> |
| 669 | <div id="ttab3" data-dojo-type="dijit/layout/ContentPane" |
| 670 | data-dojo-props='href:"getResponse.php?messId=5&delay=1000", |
| 671 | onClose:testClose, |
| 672 | closable:true |
| 673 | ' title="Tab 3"> |
| 674 | </div> |
| 675 | </div> |
| 676 | |
| 677 | <h2>AccordionContainer</h2> |
| 678 | <div data-dojo-type="dijit/layout/AccordionContainer" data-dojo-props='id:"ac", style:"height:300px; width:400px;"'> |
| 679 | <div id="ac_pane1" data-dojo-type="dijit/layout/ContentPane" data-dojo-props='title:"one", refreshOnShow:false, href:"getResponse.php?messId=4&delay=1000"'></div> |
| 680 | <div id="ac_pane2" data-dojo-type="dijit/layout/ContentPane" data-dojo-props='title:"two", refreshOnShow:true, href:"getResponse.php?messId=4&delay=4000"'></div> |
| 681 | <div id="ac_pane3" data-dojo-type="dijit/layout/ContentPane" data-dojo-props='title:"three", refreshOnShow:false, href:"getResponse.php?messId=4&delay=4100"'></div> |
| 682 | </div> |
| 683 | |
| 684 | <h2>TooltipDialog</h2> |
| 685 | <div data-dojo-type="dijit/layout/ContentPane"> |
| 686 | <div id="preloadTooltipDlgBtn" data-dojo-type="dijit/form/DropDownButton"> |
| 687 | <span>Show Preload TooltipDialog</span> |
| 688 | <div id="preloadTooltipDlg" data-dojo-type="dijit/TooltipDialog" data-dojo-props='title:"Enter Login information", preload: true, href: "doc1.html"'> |
| 689 | </div> |
| 690 | </div> |
| 691 | </div> |
| 692 | |
| 693 | <div id="noPreloadTooltipDlgBtn" data-dojo-type="dijit/form/DropDownButton"> |
| 694 | <span>Show No-Preload TooltipDialog</span> |
| 695 | <div id="noPreloadTooltipDlg" data-dojo-type="dijit/TooltipDialog" data-dojo-props='title:"Enter Login information", preload: false, href: "doc1.html"'> |
| 696 | </div> |
| 697 | </div> |
| 698 | |
| 699 | </body> |
| 700 | </html> |