~elachuni/lazr-js/treeview

« back to all changes in this revision

Viewing changes to src-js/lazrjs/activator/tests/activator.js

  • Committer: Anthony Lenton
  • Date: 2009-12-02 21:12:08 UTC
  • mfrom: (131.1.31 toolchain)
  • Revision ID: anthony.lenton@canonical.com-20091202211208-8y8xm25mj8igizz1
Merged changes from trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* Copyright (c) 2009, Canonical Ltd. All rights reserved. */
2
2
 
3
3
YUI({
4
 
    base: '../../yui/current/build/',
 
4
    base: '../../yui/',
5
5
    filter: 'raw',
6
6
    combine: false
7
7
    }).use('lazr.activator', 'lazr.testing.runner', 'node',
126
126
 
127
127
    test_renderProcessing: function() {
128
128
        this.activator.render();
129
 
        var message = Y.Node.create('<b>processing message</b>');
 
129
        var message_text = 'processing message';
 
130
        var message = Y.Node.create('<b>' + message_text + '</b>');
130
131
        Assert.isFalse(
131
132
            this.activator.get('contentBox').hasClass(
132
133
                'yui-activator-processing'),
139
140
                'yui-activator-processing'),
140
141
            'renderProcessing did not add the processing css class');
141
142
 
142
 
        var message_body = this.activator.get('contentBox').query(
 
143
        var message_body = this.activator.get('contentBox').one(
143
144
            '.yui-activator-message-body');
144
145
 
 
146
        // Opera uppercases all tags, Safari lowercases all tags,
 
147
        // and IE gets an extra _yuid attribute in the <b>.
 
148
        var added_node = message_body.one('b');
145
149
        Assert.areEqual(
146
 
            '<b>processing message</b>',
147
 
            message_body.get('innerHTML'),
 
150
            message_text,
 
151
            added_node.get('innerHTML'),
148
152
            'renderProcessing did not set the contents of the message-body');
149
153
    },
150
154
 
151
155
    test_renderCancellation: function() {
152
156
        this.activator.render();
153
 
        var message = Y.Node.create('<b>cancel message</b>');
 
157
        var message_text = 'cancel message';
 
158
        var message = Y.Node.create('<b>' + message_text + '</b>');
154
159
        Assert.isFalse(
155
160
            this.activator.get('contentBox').hasClass(
156
161
                'yui-activator-cancellation'),
163
168
                'yui-activator-cancellation'),
164
169
            'renderCancellation did not add the cancel css class');
165
170
 
166
 
        var message_body = this.activator.get('contentBox').query(
 
171
        var message_body = this.activator.get('contentBox').one(
167
172
            '.yui-activator-message-body');
 
173
        // Opera uppercases all tags, Safari lowercases all tags,
 
174
        // and IE gets an extra _yuid attribute in the <b>.
 
175
        var added_node = message_body.one('b');
168
176
        Assert.areEqual(
169
 
            '<b>cancel message</b>',
170
 
            message_body.get('innerHTML'),
 
177
            message_text,
 
178
            added_node.get('innerHTML'),
171
179
            "renderCancellation didn't set the contents of the message-body");
172
180
    },
173
181
 
233
241
            'Message body contents should still be there.');
234
242
    },
235
243
 
236
 
    test_widget_does_not_have_a_tabindex_when_focused: function() {
 
244
    test_widget_has_a_disabled_tabindex_when_focused: function() {
237
245
        // The tabindex attribute appears when the widget is focused.
238
246
        this.activator.render();
239
247
        this.activator.focus();
240
248
 
241
 
        Assert.isFalse(
242
 
            this.activator.get('boundingBox').hasAttribute('tabindex'),
243
 
            "The widget should not have a tabindex attribute.");
 
249
        // Be aware that in IE when the tabIndex is set to -1,
 
250
        // get('tabIndex') returns -1 as expected but getAttribute('tabIndex')
 
251
        // returns 65535. This is due to YUI's getAttribute() calling
 
252
        // dom_node.getAttribute('tabIndex', 2), which is an IE extension
 
253
        // that happens to treat this attribute as an unsigned integer instead
 
254
        // of as a signed integer.
 
255
        // http://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
 
256
        Assert.areEqual(
 
257
            -1,
 
258
            this.activator.get('boundingBox').get('tabIndex'),
 
259
            "The widget should have a tabindex of -1 (disabled).");
244
260
    }
245
261
}));
246
262