source: Dev/trunk/src/client/dijit/tests/layout/ContentPane-auto-require.html @ 483

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

Added Dojo 1.9.3 release.

File size: 3.4 KB
Line 
1<!DOCTYPE html>
2<html lang="en">
3<head>
4        <meta http-equiv="Content-type" content="text/html; charset=utf-8">
5        <title>ContentPane Auto Require Tests</title>
6
7        <script src="../boilerplate.js"></script>
8
9        <script type="text/javascript">
10                require([
11                        "doh",
12                        "dojo/_base/declare",
13                        "dojo/Deferred",
14                        "dojo/dom",
15                        "dojo/_base/lang",
16                        "dojo/parser",
17                        "dijit/registry",
18                        "dojo/domReady!"
19                ], function(doh, declare, Deferred, dom, lang, parser, registry){
20
21                        // instances of AsyncWidget will finish initializing when this Deferred is resolved
22                        var finishCreatingAsyncWidgets = new Deferred();
23
24                        AsyncWidget = declare(null, {
25                                declaredClass: "AsyncWidget",
26                                markupFactory: function(params, node){
27                                        // the markup factory can return a promise, and the parser will wait
28                                        return finishCreatingAsyncWidgets.then(function(){return new AsyncWidget(params, node); });
29                                },
30                                constructor: function(args, node){
31                                        this.params = args;
32                                        lang.mixin(this, args);
33                                },
34                                startup: function(){
35                                        this._started = true;
36                                }
37                        });
38
39                        doh.register("auto require", [
40                                {
41                                        name: "auto-load parse",
42                                        timeout: 5000,
43                                        runTest: function(t){
44                                                var d = new doh.Deferred();
45
46                                                // This will test auto-loading but only if dijit/form/TextBox isn't in the cache
47                                                parser.parse(dom.byId("simple")).then(d.getTestCallback(function(){
48                                                        t.is(typeof registry.byId("tb1"), "object", "objected created");
49                                                }));
50
51                                                return d;
52                                        }
53                                },
54
55                                {
56                                        name: "href",
57                                        timeout: 5000,
58                                        runTest: function(t){
59                                                var d = new doh.Deferred();
60
61                                                // This will test auto-loading but only if dijit/form/Button isn't in the cache
62                                                registry.byId("parsedPane1").set("href", "doc3.html").then(d.getTestCallback(function(){
63                                                        t.is(typeof registry.byId("button1"), "object", "object created");
64                                                }));
65
66                                                return d;
67                                        }
68                                },
69
70                                function nested(){
71                                        var d = new doh.Deferred();
72
73                                        var parsePromise = parser.parse(dom.byId("nested"));
74
75                                        // Parser should wait for innerPane Contentpane,
76                                        // innerPane should wait for nested call to parser.parse(),
77                                        // and the nested parser.parse() call is waiting for AsyncWidget to initialize.
78                                        // This is to simulate when the nested parse() call is waiting for auto-load.
79                                        doh.f(parsePromise.isFulfilled(), "parse not completed yet");
80                                        doh.f(formWidget._started, "wrapper form widget not started yet");
81
82                                        finishCreatingAsyncWidgets.resolve(true);
83
84                                        return parsePromise.then(d.getTestCallback(function(){
85                                                doh.t(formWidget._started, "wrapper form widget started");
86                                        }));
87
88                                        return d;
89                                }
90                        ]);
91                               
92                        doh.run();
93                });
94        </script>
95</head>
96<body class="claro" role="main">
97        <h1 class="testTitle">Dijit layout.ContentPane Auto-Require Tests</h1>
98
99        <h2>ContentPane Loading Content that Requires Auto-Require</h2>
100
101        <div id="simple">
102                <div data-dojo-type="dijit/layout/ContentPane" id="parsedPane1">
103                        <input type="text" aria-label="tb1" id="tb1" data-dojo-type="dijit/form/TextBox" data-dojo-props="value: 'testValue'" />
104                </div>
105        </div>
106
107        <div id="nested">
108                <div data-dojo-type="dijit/_WidgetBase" data-dojo-id="formWidget">
109                        <div data-dojo-type="dijit/layout/ContentPane" id="innerPane">
110                                <!-- for simulating an asynchronous nested parse due to waiting for module to load -->
111                                <span data-dojo-id="asyncWidget" data-dojo-type="AsyncWidget">hi</span>
112                        </div>
113                </div>
114        </div>
115
116</body>
117</html>
Note: See TracBrowser for help on using the repository browser.