~divmod-dev/divmod.org/remove-list-1507

« back to all changes in this revision

Viewing changes to Nevow/nevow/js/Nevow/Athena/Tests/__init__.js

  • Committer: mithrandi
  • Date: 2006-10-25 15:41:33 UTC
  • Revision ID: svn-v4:866e43f7-fbfc-0310-8f2a-ec88d1da2979:trunk:9746
Add a workaround for nodeById on widgets not yet added to the document in IE.

Fixes #1608
Author: mithrandi
Reviewer: exarkun

Show diffs side-by-side

added added

removed removed

Lines of Context:
286
286
        var node = self.childWidgets[0].nodeById('foo');
287
287
        self.assertEquals(node.className, 'foo');
288
288
        self.assertEquals(node.tagName.toLowerCase(), 'span');
 
289
    },
 
290
 
 
291
    /**
 
292
     * Test that nodeById throws NodeNotFound when the node cannot be located.
 
293
     */
 
294
    function test_nodeByIdNotFound(self) {
 
295
        var _find = function () { return self.childWidgets[0].nodeById('nonexistent'); };
 
296
        self.assertThrows(Divmod.Runtime.NodeNotFound, _find);
 
297
    },
 
298
 
 
299
    function addDynamicWidget(self, child) {
 
300
        var d = child.callRemote('getDynamicWidget');
 
301
        d.addCallback(
 
302
            function (widgetInfo) {
 
303
                return child.addChildWidgetFromWidgetInfo(widgetInfo);
 
304
            });
 
305
        return d;
 
306
    },
 
307
 
 
308
    /**
 
309
     * Test that nodeById is able to locate nodes in a dynamically instantiated
 
310
     * widget that has not yet been added as a child somewhere in the browser
 
311
     * document.
 
312
     */
 
313
    function test_nodeByIdInDynamicOrphan(self) {
 
314
        var child = self.childWidgets[1];
 
315
        var d = self.addDynamicWidget(child);
 
316
        d.addCallback(
 
317
            function (widget) {
 
318
                var node = widget.nodeById('foo');
 
319
                self.assertEquals(node.className, 'foo');
 
320
                self.assertEquals(node.tagName.toLowerCase(), 'span');
 
321
            });
 
322
        return d;
 
323
    },
 
324
 
 
325
    /**
 
326
     * Test that nodeById is able to locate nodes in a dynamically instantiated
 
327
     * widget that has already been added as a child somewhere in the browser
 
328
     * document.
 
329
     */
 
330
    function test_nodeByIdInDynamicChild(self) {
 
331
        var child = self.childWidgets[1];
 
332
        var d = self.addDynamicWidget(child);
 
333
        d.addCallback(
 
334
            function (widget) {
 
335
                child.node.appendChild(widget.node);
 
336
                var node = widget.nodeById('foo');
 
337
                self.assertEquals(node.className, 'foo');
 
338
                self.assertEquals(node.tagName.toLowerCase(), 'span');
 
339
            });
 
340
        return d;
 
341
    },
 
342
 
 
343
    function test_nodeByIdNotFoundInDynamicOrphan(self) {
 
344
        var child = self.childWidgets[1];
 
345
        var d = self.addDynamicWidget(child);
 
346
        d.addCallback(
 
347
            function (widget) {
 
348
                var _find = function () { return widget.nodeById('nonexistent'); };
 
349
                self.assertThrows(Divmod.Runtime.NodeNotFound, _find);
 
350
            });
 
351
        return d;
289
352
    });
290
353
 
291
354