//  ========================================================================
/**
 * @copyright Copyright (C) 1999 Technical Pursuit Inc. (TPI) All Rights
 *     Reserved. Patents Pending, Technical Pursuit Inc. Licensed under the
 *     OSI-approved Reciprocal Public License (RPL) Version 1.5. See the RPL
 *     for your rights and responsibilities. Contact TPI to purchase optional
 *     privacy waivers if you must keep your TIBET-based source code private.
 */
//  ========================================================================

//  ========================================================================
//  html:
//  ========================================================================

TP.html.XMLNS.Type.describe('html: set content of standard elements',
function() {

    var loadURI,
        unloadURI,

        testData,

        windowContext;

    loadURI = TP.uc('~lib_test/src/html/HTMLContent.xhtml');

    unloadURI = TP.uc(TP.sys.cfg('path.blank_page'));

    //  ---

    this.before(
        async function(suite, options) {

            TP.$$setupCommonObjectValues();
            testData = TP.$$commonObjectValues;

            windowContext = this.getDriver().get('windowContext');

            await this.getDriver().setLocation(loadURI);
        });

    //  ---

    this.after(
        async function(suite, options) {

            //  Unload the current page by setting it to the blank
            await this.getDriver().setLocation(unloadURI);

            //  Unregister the URI to avoid a memory leak
            loadURI.unregister();
        });

    //  ---

    this.it('inline element - setting content to scalar values', async function(test, options) {

        var tpElem,
            content;

        tpElem = TP.byId('span', windowContext);

        //  undefined (won't alter content)
        await tpElem.set('content', testData.at(TP.UNDEF));
        content = tpElem.get('content');
        test.assert.isEqualTo(content, '');

        //  null (won't alter content)
        await tpElem.set('content', testData.at(TP.NULL));
        content = tpElem.get('content');
        test.assert.isEqualTo(content, '');

        //  String
        await tpElem.set('content', testData.at('String'));
        content = tpElem.get('content');
        test.assert.isEqualTo(content, testData.at('String'));

        tpElem.get('nativeNode').innerHTML = '';

        //  Number
        await tpElem.set('content', testData.at('Number'));
        content = tpElem.get('content');
        test.assert.isEqualTo(content.asNumber(), testData.at('Number'));

        tpElem.get('nativeNode').innerHTML = '';

        //  Boolean
        await tpElem.set('content', testData.at('Boolean'));
        content = tpElem.get('content');
        test.assert.isEqualTo(content.asBoolean(), testData.at('Boolean'));

        tpElem.get('nativeNode').innerHTML = '';
    });

    //  ---

    this.it('inline element - setting content to complex object values', async function(test, options) {

        var tpElem,
            content;

        tpElem = TP.byId('span', windowContext);

        //  RegExp
        await tpElem.set('content', testData.at('RegExp'));
        content = tpElem.get('content');
        test.assert.isEqualTo(content, TP.str(testData.at('RegExp')));

        //  Date
        await tpElem.set('content', testData.at('Date'));
        content = tpElem.get('content');
        test.assert.isEqualTo(content, TP.str(testData.at('Date')));

        //  Array
        await tpElem.set('content', testData.at('Array'));
        content = tpElem.get('content');
        test.assert.isEqualTo(content, TP.str(testData.at('Array')));

        //  Object
        await tpElem.set('content', testData.at('Object'));
        content = tpElem.get('content');
        test.assert.isEqualTo(content, TP.str(testData.at('Object')));

        //  TP.core.Hash
        await tpElem.set('content', testData.at('TP.core.Hash'));
        content = tpElem.get('content');
        test.assert.isEqualTo(content, TP.str(testData.at('TP.core.Hash')));
    });

    //  ---

    this.it('inline element - setting content to markup String', async function(test, options) {

        var tpElem,
            content;

        tpElem = TP.byId('span', windowContext);

        await tpElem.set('content', '<h6 xmlns="http://www.w3.org/1999/xhtml">Hi</h6>');
        tpElem.getFirstChildElement().removeAttribute('id');

        content = tpElem.get('content');
        test.assert.isEqualTo(content, '<h6 xmlns="http://www.w3.org/1999/xhtml">Hi</h6>');

        tpElem.get('nativeNode').innerHTML = '';
    });

    //  ---

    this.it('block element - setting content to scalar values', async function(test, options) {

        var tpElem,
            content;

        tpElem = TP.byId('div', windowContext);

        //  undefined (won't alter content)
        await tpElem.set('content', testData.at(TP.UNDEF));
        content = tpElem.get('content');
        test.assert.isEqualTo(content, '');

        //  null (won't alter content)
        await tpElem.set('content', testData.at(TP.NULL));
        content = tpElem.get('content');
        test.assert.isEqualTo(content, '');

        //  String
        await tpElem.set('content', testData.at('String'));
        content = tpElem.get('content');
        test.assert.isEqualTo(content, testData.at('String'));

        tpElem.get('nativeNode').innerHTML = '';

        //  Number
        await tpElem.set('content', testData.at('Number'));
        content = tpElem.get('content');
        test.assert.isEqualTo(content.asNumber(), testData.at('Number'));

        tpElem.get('nativeNode').innerHTML = '';

        //  Boolean
        await tpElem.set('content', testData.at('Boolean'));
        content = tpElem.get('content');
        test.assert.isEqualTo(content.asBoolean(), testData.at('Boolean'));

        tpElem.get('nativeNode').innerHTML = '';
    });

    //  ---

    this.it('block element - setting content to complex object values', async function(test, options) {

        var tpElem,
            content;

        tpElem = TP.byId('div', windowContext);

        //  RegExp
        await tpElem.set('content', testData.at('RegExp'));
        content = tpElem.get('content');
        test.assert.isEqualTo(content, TP.str(testData.at('RegExp')));

        //  Date
        await tpElem.set('content', testData.at('Date'));
        content = tpElem.get('content');
        test.assert.isEqualTo(content, TP.str(testData.at('Date')));

        //  Array
        await tpElem.set('content', testData.at('Array'));
        content = tpElem.get('content');
        test.assert.isEqualTo(content, TP.str(testData.at('Array')));

        //  Object
        await tpElem.set('content', testData.at('Object'));
        content = tpElem.get('content');
        test.assert.isEqualTo(content, TP.str(testData.at('Object')));

        //  TP.core.Hash
        await tpElem.set('content', testData.at('TP.core.Hash'));
        content = tpElem.get('content');
        test.assert.isEqualTo(content, TP.str(testData.at('TP.core.Hash')));
    });

    //  ---

    this.it('block element - setting content to markup String', async function(test, options) {

        var tpElem,
            content;

        tpElem = TP.byId('div', windowContext);

        await tpElem.set('content', '<h6 xmlns="http://www.w3.org/1999/xhtml">Hi</h6>');
        tpElem.getFirstChildElement().removeAttribute('id');

        content = tpElem.get('content');
        test.assert.isEqualTo(content, '<h6 xmlns="http://www.w3.org/1999/xhtml">Hi</h6>');

        tpElem.get('nativeNode').innerHTML = '';
    });

    //  ---

    this.it('input type="text" element - setting content to scalar values', async function(test, options) {

        var tpElem,
            content;

        tpElem = TP.byId('input_text', windowContext);

        //  undefined (won't alter content)
        await tpElem.set('content', testData.at(TP.UNDEF));
        content = tpElem.get('content');
        test.assert.isNull(content);

        //  null (won't alter content)
        await tpElem.set('content', testData.at(TP.NULL));
        content = tpElem.get('content');
        test.assert.isNull(content);

        //  String (won't alter content)
        await tpElem.set('content', testData.at('String'));
        content = tpElem.get('content');
        test.assert.isNull(content);

        //  Number (won't alter content)
        await tpElem.set('content', testData.at('Number'));
        content = tpElem.get('content');
        test.assert.isNull(content);

        //  Boolean (won't alter content)
        await tpElem.set('content', testData.at('Boolean'));
        content = tpElem.get('content');
        test.assert.isNull(content);
    });

    //  ---

    this.it('input type="text" element - setting content to complex object values', async function(test, options) {

        var tpElem,
            content;

        tpElem = TP.byId('input_text', windowContext);

        //  RegExp (won't alter content)
        await tpElem.set('content', testData.at('RegExp'));
        content = tpElem.get('content');
        test.assert.isNull(content);

        //  Date (won't alter content)
        await tpElem.set('content', testData.at('Date'));
        content = tpElem.get('content');
        test.assert.isNull(content);

        //  Array (won't alter content)
        await tpElem.set('content', testData.at('Array'));
        content = tpElem.get('content');
        test.assert.isNull(content);

        //  Object (won't alter content)
        await tpElem.set('content', testData.at('Object'));
        content = tpElem.get('content');
        test.assert.isNull(content);

        //  TP.core.Hash (won't alter content)
        await tpElem.set('content', testData.at('TP.core.Hash'));
        content = tpElem.get('content');
        test.assert.isNull(content);
    });

    //  ---

    this.it('input type="text" element - setting content to markup String', async function(test, options) {

        var tpElem,
            content;

        tpElem = TP.byId('input_text', windowContext);

        //  Markup String (won't alter content)
        await tpElem.set('content', '<h6 xmlns="http://www.w3.org/1999/xhtml">Hi</h6>');
        content = tpElem.get('content');
        test.assert.isNull(content);
    });

    //  ---

    this.it('textarea element - setting content to scalar values', async function(test, options) {

        var tpElem,
            content;

        tpElem = TP.byId('textarea', windowContext);

        //  undefined (won't alter content)
        await tpElem.set('content', testData.at(TP.UNDEF));
        content = tpElem.get('content');
        test.assert.isEqualTo(content, '');

        //  null (won't alter content)
        await tpElem.set('content', testData.at(TP.NULL));
        content = tpElem.get('content');
        test.assert.isEqualTo(content, '');

        //  String
        await tpElem.set('content', testData.at('String'));
        content = tpElem.get('content');
        test.assert.isEqualTo(content, testData.at('String'));

        tpElem.get('nativeNode').innerHTML = '';

        //  Number
        await tpElem.set('content', testData.at('Number'));
        content = tpElem.get('content');
        test.assert.isEqualTo(content.asNumber(), testData.at('Number'));

        tpElem.get('nativeNode').innerHTML = '';

        //  Boolean
        await tpElem.set('content', testData.at('Boolean'));
        content = tpElem.get('content');
        test.assert.isEqualTo(content.asBoolean(), testData.at('Boolean'));

        tpElem.get('nativeNode').innerHTML = '';
    });

    //  ---

    this.it('textarea element - setting content to complex object values', async function(test, options) {

        var tpElem,
            content;

        tpElem = TP.byId('textarea', windowContext);

        //  RegExp
        await tpElem.set('content', testData.at('RegExp'));
        content = tpElem.get('content');
        test.assert.isEqualTo(content, TP.str(testData.at('RegExp')));

        //  Date
        await tpElem.set('content', testData.at('Date'));
        content = tpElem.get('content');
        test.assert.isEqualTo(content, TP.str(testData.at('Date')));

        //  Array
        await tpElem.set('content', testData.at('Array'));
        content = tpElem.get('content');
        test.assert.isEqualTo(content, TP.str(testData.at('Array')));

        //  Object
        await tpElem.set('content', testData.at('Object'));
        content = tpElem.get('content');
        test.assert.isEqualTo(content, TP.str(testData.at('Object')));

        //  TP.core.Hash
        await tpElem.set('content', testData.at('TP.core.Hash'));
        content = tpElem.get('content');
        test.assert.isEqualTo(content, TP.str(testData.at('TP.core.Hash')));
    });

    //  ---

    this.it('textarea element - setting content to markup String', async function(test, options) {

        var tpElem,
            content;

        tpElem = TP.byId('textarea', windowContext);

        await tpElem.set('content', '<h6 xmlns="http://www.w3.org/1999/xhtml">Hi</h6>');
        tpElem.getFirstChildElement().removeAttribute('id');

        content = tpElem.get('content');
        test.assert.isEqualTo(content, '<h6 xmlns="http://www.w3.org/1999/xhtml">Hi</h6>');

        tpElem.get('nativeNode').innerHTML = '';
    });

    //  ---

    this.it('select element - setting content to scalar values', async function(test, options) {

        var tpElem,
            content;

        tpElem = TP.byId('select_single', windowContext);

        //  undefined (won't alter content)
        await tpElem.set('content', testData.at(TP.UNDEF));
        content = tpElem.get('content');
        content = content.trim().strip(TP.regex.XMLNS_STRIP);
        test.assert.isEqualTo(content, '<option id="select_single_1" value="foo">Dog</option><option id="select_single_2" value="bar">Cat</option><option id="select_single_3" value="baz">Fish</option>');

        //  null (won't alter content)
        await tpElem.set('content', testData.at(TP.NULL));
        content = tpElem.get('content');
        content = content.trim().strip(TP.regex.XMLNS_STRIP);
        test.assert.isEqualTo(content, '<option id="select_single_1" value="foo">Dog</option><option id="select_single_2" value="bar">Cat</option><option id="select_single_3" value="baz">Fish</option>');

        //  String
        await tpElem.set('content', 'Hi');
        content = tpElem.get('content');
        test.assert.isEqualTo(content, 'Hi');
        tpElem.get('nativeNode').innerHTML = '<option id="select_single_1" value="foo">Dog</option><option id="select_single_2" value="bar">Cat</option><option id="select_single_3" value="baz">Fish</option>';

        //  Number
        await tpElem.set('content', 42);
        content = tpElem.get('content');
        test.assert.isEqualTo(content.asNumber(), 42);
        tpElem.get('nativeNode').innerHTML = '<option id="select_single_1" value="foo">Dog</option><option id="select_single_2" value="bar">Cat</option><option id="select_single_3" value="baz">Fish</option>';

        //  Boolean
        await tpElem.set('content', true);
        content = tpElem.get('content');
        test.assert.isEqualTo(content.asBoolean(), true);
        tpElem.get('nativeNode').innerHTML = '<option id="select_single_1" value="foo">Dog</option><option id="select_single_2" value="bar">Cat</option><option id="select_single_3" value="baz">Fish</option>';
    });

    //  ---

    this.it('select element - setting content to complex object values', async function(test, options) {

        var tpElem,
            content;

        tpElem = TP.byId('select_single', windowContext);

        //  RegExp
        await tpElem.set('content', testData.at('RegExp'));
        content = tpElem.get('content');
        test.assert.isEqualTo(content, TP.str(testData.at('RegExp')));
        tpElem.get('nativeNode').innerHTML = '<option id="select_single_1" value="foo">Dog</option><option id="select_single_2" value="bar">Cat</option><option id="select_single_3" value="baz">Fish</option>';

        //  Date
        await tpElem.set('content', testData.at('Date'));
        content = tpElem.get('content');
        test.assert.isEqualTo(content, TP.str(testData.at('Date')));
        tpElem.get('nativeNode').innerHTML = '<option id="select_single_1" value="foo">Dog</option><option id="select_single_2" value="bar">Cat</option><option id="select_single_3" value="baz">Fish</option>';

        //  Array
        await tpElem.set('content', testData.at('Array'));
        content = tpElem.get('content');
        test.assert.isEqualTo(content, TP.str(testData.at('Array')));
        tpElem.get('nativeNode').innerHTML = '<option id="select_single_1" value="foo">Dog</option><option id="select_single_2" value="bar">Cat</option><option id="select_single_3" value="baz">Fish</option>';

        //  Object
        await tpElem.set('content', testData.at('Object'));
        content = tpElem.get('content');
        test.assert.isEqualTo(content, TP.str(testData.at('Object')));
        tpElem.get('nativeNode').innerHTML = '<option id="select_single_1" value="foo">Dog</option><option id="select_single_2" value="bar">Cat</option><option id="select_single_3" value="baz">Fish</option>';

        //  TP.core.Hash
        await tpElem.set('content', testData.at('TP.core.Hash'));
        content = tpElem.get('content');
        test.assert.isEqualTo(content, TP.str(testData.at('TP.core.Hash')));
        tpElem.get('nativeNode').innerHTML = '<option id="select_single_1" value="foo">Dog</option><option id="select_single_2" value="bar">Cat</option><option id="select_single_3" value="baz">Fish</option>';
    });

    //  ---

    this.it('select element - setting content to markup String', async function(test, options) {

        var tpElem,
            content;

        tpElem = TP.byId('select_single', windowContext);

        await tpElem.set('content', '<h6 xmlns="http://www.w3.org/1999/xhtml">Hi</h6>');
        content = tpElem.get('content');
        test.assert.isEqualTo(content, '<h6 xmlns="http://www.w3.org/1999/xhtml">Hi</h6>');

        tpElem.get('nativeNode').innerHTML = '<option id="select_single_1" value="foo">Dog</option><option id="select_single_2" value="bar">Cat</option><option id="select_single_3" value="baz">Fish</option>';
    });

    //  ---

    this.it('select (multiple) element - setting content to scalar values', async function(test, options) {

        var tpElem,
            content;

        tpElem = TP.byId('select_multiple', windowContext);

        //  undefined (won't alter content)
        await tpElem.set('content', testData.at(TP.UNDEF));
        content = tpElem.get('content');
        content = content.trim().strip(TP.regex.XMLNS_STRIP);
        test.assert.isEqualTo(content, '<option id="select_multiple_1" value="foo">Red</option><option id="select_multiple_2" value="bar">Blue</option><option id="select_multiple_3" value="baz">Yellow</option>');

        //  null (won't alter content)
        await tpElem.set('content', testData.at(TP.NULL));
        content = tpElem.get('content');
        content = content.trim().strip(TP.regex.XMLNS_STRIP);
        test.assert.isEqualTo(content, '<option id="select_multiple_1" value="foo">Red</option><option id="select_multiple_2" value="bar">Blue</option><option id="select_multiple_3" value="baz">Yellow</option>');

        //  String
        await tpElem.set('content', 'Hi');
        content = tpElem.get('content');
        test.assert.isEqualTo(content, 'Hi');
        tpElem.get('nativeNode').innerHTML = '<option id="select_multiple_1" value="foo">Red</option><option id="select_multiple_2" value="bar">Blue</option><option id="select_multiple_3" value="baz">Yellow</option>';

        //  Number
        await tpElem.set('content', 42);
        content = tpElem.get('content');
        test.assert.isEqualTo(content.asNumber(), 42);
        tpElem.get('nativeNode').innerHTML = '<option id="select_multiple_1" value="foo">Red</option><option id="select_multiple_2" value="bar">Blue</option><option id="select_multiple_3" value="baz">Yellow</option>';

        //  Boolean
        await tpElem.set('content', true);
        content = tpElem.get('content');
        test.assert.isEqualTo(content.asBoolean(), true);
        tpElem.get('nativeNode').innerHTML = '<option id="select_multiple_1" value="foo">Red</option><option id="select_multiple_2" value="bar">Blue</option><option id="select_multiple_3" value="baz">Yellow</option>';
    });

    //  ---

    this.it('select (multiple) element - setting content to complex object values', async function(test, options) {

        var tpElem,
            content;

        tpElem = TP.byId('select_multiple', windowContext);

        //  RegExp
        await tpElem.set('content', testData.at('RegExp'));
        content = tpElem.get('content');
        test.assert.isEqualTo(content, TP.str(testData.at('RegExp')));
        tpElem.get('nativeNode').innerHTML = '<option id="select_multiple_1" value="foo">Red</option><option id="select_multiple_2" value="bar">Blue</option><option id="select_multiple_3" value="baz">Yellow</option>';

        //  Date
        await tpElem.set('content', testData.at('Date'));
        content = tpElem.get('content');
        test.assert.isEqualTo(content, TP.str(testData.at('Date')));
        tpElem.get('nativeNode').innerHTML = '<option id="select_multiple_1" value="foo">Red</option><option id="select_multiple_2" value="bar">Blue</option><option id="select_multiple_3" value="baz">Yellow</option>';

        //  Array
        await tpElem.set('content', testData.at('Array'));
        content = tpElem.get('content');
        test.assert.isEqualTo(content, TP.str(testData.at('Array')));
        tpElem.get('nativeNode').innerHTML = '<option id="select_multiple_1" value="foo">Red</option><option id="select_multiple_2" value="bar">Blue</option><option id="select_multiple_3" value="baz">Yellow</option>';

        //  Object
        await tpElem.set('content', testData.at('Object'));
        content = tpElem.get('content');
        test.assert.isEqualTo(content, TP.str(testData.at('Object')));
        tpElem.get('nativeNode').innerHTML = '<option id="select_multiple_1" value="foo">Red</option><option id="select_multiple_2" value="bar">Blue</option><option id="select_multiple_3" value="baz">Yellow</option>';

        //  TP.core.Hash
        await tpElem.set('content', testData.at('TP.core.Hash'));
        content = tpElem.get('content');
        test.assert.isEqualTo(content, TP.str(testData.at('TP.core.Hash')));
        tpElem.get('nativeNode').innerHTML = '<option id="select_multiple_1" value="foo">Red</option><option id="select_multiple_2" value="bar">Blue</option><option id="select_multiple_3" value="baz">Yellow</option>';
    });

    //  ---

    this.it('select (multiple) element - setting content to markup String', async function(test, options) {

        var tpElem,
            content;

        tpElem = TP.byId('select_multiple', windowContext);

        await tpElem.set('content', '<h6 xmlns="http://www.w3.org/1999/xhtml">Hi</h6>');
        content = tpElem.get('content');
        test.assert.isEqualTo(content, '<h6 xmlns="http://www.w3.org/1999/xhtml">Hi</h6>');

        tpElem.get('nativeNode').innerHTML = '<option id="select_multiple_1" value="foo">Red</option><option id="select_multiple_2" value="bar">Blue</option><option id="select_multiple_3" value="baz">Yellow</option>';
    });

    //  ---

    this.it('input type="radio" element - setting content to scalar values', async function(test, options) {

        var tpElem,
            content;

        tpElem = TP.byId('input_radio_3', windowContext);

        //  undefined (won't alter content)
        await tpElem.set('content', testData.at(TP.UNDEF));
        content = tpElem.get('content');
        test.assert.isNull(content);

        //  null (won't alter content)
        await tpElem.set('content', testData.at(TP.NULL));
        content = tpElem.get('content');
        test.assert.isNull(content);

        //  String (won't alter content)
        await tpElem.set('content', testData.at('String'));
        content = tpElem.get('content');
        test.assert.isNull(content);

        //  Number (won't alter content)
        await tpElem.set('content', testData.at('Number'));
        content = tpElem.get('content');
        test.assert.isNull(content);

        //  Boolean (won't alter content)
        await tpElem.set('content', testData.at('Boolean'));
        content = tpElem.get('content');
        test.assert.isNull(content);
    });

    //  ---

    this.it('input type="radio" element - setting content to complex object values', async function(test, options) {

        var tpElem,
            content;

        tpElem = TP.byId('input_radio_3', windowContext);

        //  RegExp (won't alter content)
        await tpElem.set('content', testData.at('RegExp'));
        content = tpElem.get('content');
        test.assert.isNull(content);

        //  Date (won't alter content)
        await tpElem.set('content', testData.at('Date'));
        content = tpElem.get('content');
        test.assert.isNull(content);

        //  Array (won't alter content)
        await tpElem.set('content', testData.at('Array'));
        content = tpElem.get('content');
        test.assert.isNull(content);

        //  Object (won't alter content)
        await tpElem.set('content', testData.at('Object'));
        content = tpElem.get('content');
        test.assert.isNull(content);

        //  TP.core.Hash (won't alter content)
        await tpElem.set('content', testData.at('TP.core.Hash'));
        content = tpElem.get('content');
        test.assert.isNull(content);
    });

    //  ---

    this.it('input type="radio" element - setting content to markup String', async function(test, options) {

        var tpElem,
            content;

        tpElem = TP.byId('input_radio_3', windowContext);

        //  Markup String (won't alter content)
        await tpElem.set('content', '<h6 xmlns="http://www.w3.org/1999/xhtml">Hi</h6>');
        content = tpElem.get('content');
        test.assert.isNull(content);
    });

    //  ---

    this.it('input type="checkbox" element - setting content to scalar values', async function(test, options) {

        var tpElem,
            content;

        tpElem = TP.byId('input_checkbox_3', windowContext);

        //  undefined (won't alter content)
        await tpElem.set('content', testData.at(TP.UNDEF));
        content = tpElem.get('content');
        test.assert.isNull(content);

        //  null (won't alter content)
        await tpElem.set('content', testData.at(TP.NULL));
        content = tpElem.get('content');
        test.assert.isNull(content);

        //  String (won't alter content)
        await tpElem.set('content', testData.at('String'));
        content = tpElem.get('content');
        test.assert.isNull(content);

        //  Number (won't alter content)
        await tpElem.set('content', testData.at('Number'));
        content = tpElem.get('content');
        test.assert.isNull(content);

        //  Boolean (won't alter content)
        await tpElem.set('content', testData.at('Boolean'));
        content = tpElem.get('content');
        test.assert.isNull(content);
    });

    //  ---

    this.it('input type="checkbox" element - setting content to complex object values', async function(test, options) {

        var tpElem,
            content;

        tpElem = TP.byId('input_checkbox_3', windowContext);

        //  RegExp (won't alter content)
        await tpElem.set('content', testData.at('RegExp'));
        content = tpElem.get('content');
        test.assert.isNull(content);

        //  Date (won't alter content)
        await tpElem.set('content', testData.at('Date'));
        content = tpElem.get('content');
        test.assert.isNull(content);

        //  Array (won't alter content)
        await tpElem.set('content', testData.at('Array'));
        content = tpElem.get('content');
        test.assert.isNull(content);

        //  Object (won't alter content)
        await tpElem.set('content', testData.at('Object'));
        content = tpElem.get('content');
        test.assert.isNull(content);

        //  TP.core.Hash (won't alter content)
        await tpElem.set('content', testData.at('TP.core.Hash'));
        content = tpElem.get('content');
        test.assert.isNull(content);
    });

    //  ---

    this.it('input type="checkbox" element - setting content to markup String', async function(test, options) {

        var tpElem,
            content;

        tpElem = TP.byId('input_checkbox_3', windowContext);

        //  Markup String (won't alter content)
        await tpElem.set('content', '<h6 xmlns="http://www.w3.org/1999/xhtml">Hi</h6>');
        content = tpElem.get('content');
        test.assert.isNull(content);
    });
});

//  ------------------------------------------------------------------------

TP.html.XMLNS.Type.describe('html: set value of standard elements',
function() {

    var testData,

        windowContext;

    this.before(
        async function(suite, options) {
            var testDataLoc,
                loadURI;

            TP.$$setupCommonObjectValues();
            testData = TP.$$commonObjectValues;

            testDataLoc = '~lib_test/src/html/HTMLContent.xhtml';
            loadURI = TP.uc(testDataLoc);

            windowContext = this.getDriver().get('windowContext');

            await this.getDriver().setLocation(loadURI);
        });

    //  ---

    this.it('inline element - setting value to scalar values', async function(test, options) {

        var tpElem,
            value;

        tpElem = TP.byId('span', windowContext);

        //  undefined (won't alter value)
        await tpElem.set('value', testData.at(TP.UNDEF));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, '');

        //  null (won't alter value)
        await tpElem.set('value', testData.at(TP.NULL));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, '');

        //  String
        await tpElem.set('value', testData.at('String'));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, testData.at('String'));

        //  Number
        await tpElem.set('value', testData.at('Number'));
        value = tpElem.get('value');
        test.assert.isEqualTo(value.asNumber(), testData.at('Number'));

        //  Boolean
        await tpElem.set('value', testData.at('Boolean'));
        value = tpElem.get('value');
        test.assert.isEqualTo(value.asBoolean(), testData.at('Boolean'));
    });

    //  ---

    this.it('inline element - setting value to complex object values', async function(test, options) {

        var tpElem,
            value;

        tpElem = TP.byId('span', windowContext);

        //  RegExp
        await tpElem.set('value', testData.at('RegExp'));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, TP.str(testData.at('RegExp')));

        //  Date
        await tpElem.set('value', testData.at('Date'));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, TP.str(testData.at('Date')));

        //  Array
        await tpElem.set('value', testData.at('Array'));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, TP.str(testData.at('Array')));

        //  Object
        await tpElem.set('value', testData.at('Object'));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, TP.str(testData.at('Object')));

        //  TP.core.Hash
        await tpElem.set('value', testData.at('TP.core.Hash'));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, TP.str(testData.at('TP.core.Hash')));
    });

    //  ---

    this.it('inline element - setting value to markup', async function(test, options) {

        var tpElem,
            value;

        tpElem = TP.byId('span', windowContext);

        //  XMLDocument
        await tpElem.set('value', TP.nodeCloneNode(testData.at('XMLDocument')));

        value = tpElem.get('value');
        value = value.
                    strip(/ xml:base=".+?"/g).
                    strip(/ xmlns:xml=".+?"/g).
                    strip(/ xmlns:tibet=".+?"/g).
                    strip(/ tibet:globaldocid=".+?"/g).
                    strip(/ tibet:no-compile="true"/g).
                    strip(/ id=".+?"/g);

        test.assert.isEqualTo(
            value, '<foo bar="baz">Hi there<boo><goo/></boo><moo/></foo>');

        //  XMLElement
        await tpElem.set('value', TP.nodeCloneNode(testData.at('XMLElement')));
        value = tpElem.get('value');
        value = value.
                    strip(/ xmlns:tibet=".+?"/g).
                    strip(/ tibet:no-compile="true"/g);

        test.assert.matches(value, /<foo id=".+">bar<\/foo>/);

        //  AttributeNode
        await tpElem.set('value', TP.nodeCloneNode(testData.at('AttributeNode')));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, 'foo="bar"');

        //  TextNode
        await tpElem.set('value', TP.nodeCloneNode(testData.at('TextNode')));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, 'foo');

        //  CDATASectionNode
        await tpElem.set('value', TP.nodeCloneNode(testData.at('CDATASectionNode')));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, '<![CDATA[foo]]>');

        //  PINode
        await tpElem.set('value', TP.nodeCloneNode(testData.at('PINode')));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, '<?foo bar?>');

        //  CommentNode
        await tpElem.set('value', TP.nodeCloneNode(testData.at('CommentNode')));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, '<!--foo-->');

        //  DocumentFragmentNode
        await tpElem.set('value', TP.nodeCloneNode(testData.at('DocumentFragmentNode')));
        value = tpElem.get('value');
        value = value.
                    strip(/ xmlns:tibet=".+?"/g).
                    strip(/ tibet:no-compile="true"/g).
                    strip(/ id=".+?"/g);
        test.assert.isEqualTo(value, '<foo>foo</foo><bar>bar</bar>');

        //  NodeList
        await tpElem.set('value', testData.at('NodeList'));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, 'Hi there<boo><goo/></boo><moo/>');

        //  NamedNodeMap
        await tpElem.set('value', testData.at('NamedNodeMap'));
        value = tpElem.get('value');
        test.assert.matches(value, /bar: baz/);
    });

    //  ---

    this.it('block element - setting value to scalar values', async function(test, options) {

        var tpElem,
            value;

        tpElem = TP.byId('div', windowContext);

        //  undefined (won't alter value)
        await tpElem.set('value', testData.at(TP.UNDEF));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, '');

        //  null (won't alter value)
        await tpElem.set('value', testData.at(TP.NULL));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, '');

        //  String
        await tpElem.set('value', testData.at('String'));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, testData.at('String'));

        //  Number
        await tpElem.set('value', testData.at('Number'));
        value = tpElem.get('value');
        test.assert.isEqualTo(value.asNumber(), testData.at('Number'));

        //  Boolean
        await tpElem.set('value', testData.at('Boolean'));
        value = tpElem.get('value');
        test.assert.isEqualTo(value.asBoolean(), testData.at('Boolean'));
    });

    //  ---

    this.it('block element - setting value to complex object values', async function(test, options) {

        var tpElem,
            value;

        tpElem = TP.byId('div', windowContext);

        //  RegExp
        await tpElem.set('value', testData.at('RegExp'));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, TP.str(testData.at('RegExp')));

        //  Date
        await tpElem.set('value', testData.at('Date'));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, TP.str(testData.at('Date')));

        //  Array
        await tpElem.set('value', testData.at('Array'));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, TP.str(testData.at('Array')));

        //  Object
        await tpElem.set('value', testData.at('Object'));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, TP.str(testData.at('Object')));

        //  TP.core.Hash
        await tpElem.set('value', testData.at('TP.core.Hash'));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, TP.str(testData.at('TP.core.Hash')));
    });

    //  ---

    this.it('block element - setting value to markup', async function(test, options) {

        var tpElem,
            value;

        tpElem = TP.byId('div', windowContext);

        //  XMLDocument
        await tpElem.set('value', TP.nodeCloneNode(testData.at('XMLDocument')));
        value = tpElem.get('value');
        value = value.
                    strip(/ xml:base=".+?"/g).
                    strip(/ xmlns:xml=".+?"/g).
                    strip(/ xmlns:tibet=".+?"/g).
                    strip(/ tibet:globaldocid=".+?"/g).
                    strip(/ tibet:no-compile="true"/g).
                    strip(/ id=".+?"/g);

        test.assert.isEqualTo(
            value, '<foo bar="baz">Hi there<boo><goo/></boo><moo/></foo>');

        //  XMLElement
        await tpElem.set('value', TP.nodeCloneNode(testData.at('XMLElement')));
        value = tpElem.get('value');
        value = value.
                    strip(/ xmlns:tibet=".+?"/g).
                    strip(/ tibet:no-compile="true"/g);

        test.assert.matches(value, /<foo id=".+">bar<\/foo>/);

        //  AttributeNode
        await tpElem.set('value', TP.nodeCloneNode(testData.at('AttributeNode')));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, 'foo="bar"');

        //  TextNode
        await tpElem.set('value', TP.nodeCloneNode(testData.at('TextNode')));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, 'foo');

        //  CDATASectionNode
        await tpElem.set('value', TP.nodeCloneNode(testData.at('CDATASectionNode')));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, '<![CDATA[foo]]>');

        //  PINode
        await tpElem.set('value', TP.nodeCloneNode(testData.at('PINode')));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, '<?foo bar?>');

        //  CommentNode
        await tpElem.set('value', TP.nodeCloneNode(testData.at('CommentNode')));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, '<!--foo-->');

        //  DocumentFragmentNode
        await tpElem.set('value', TP.nodeCloneNode(testData.at('DocumentFragmentNode')));
        value = tpElem.get('value');
        value = value.
                    strip(/ xmlns:tibet=".+?"/g).
                    strip(/ tibet:no-compile="true"/g).
                    strip(/ id=".+?"/g);
        test.assert.isEqualTo(value, '<foo>foo</foo><bar>bar</bar>');

        //  NodeList
        await tpElem.set('value', testData.at('NodeList'));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, 'Hi there<boo><goo/></boo><moo/>');

        //  NamedNodeMap
        await tpElem.set('value', testData.at('NamedNodeMap'));
        value = tpElem.get('value');
        test.assert.matches(value, /bar: baz/);
    });

    //  ---

    this.it('input type="text" element - setting value to scalar values', async function(test, options) {

        var tpElem,
            value;

        tpElem = TP.byId('input_text', windowContext);

        //  undefined
        await tpElem.set('value', testData.at(TP.UNDEF));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, TP.str(''));

        //  null
        await tpElem.set('value', testData.at(TP.NULL));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, TP.str(''));

        //  String
        await tpElem.set('value', testData.at('String'));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, TP.str(testData.at('String')));

        //  Number
        await tpElem.set('value', testData.at('Number'));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, TP.str(testData.at('Number')));

        //  Boolean
        await tpElem.set('value', testData.at('Boolean'));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, TP.str(testData.at('Boolean')));
    });

    //  ---

    this.it('input type="text" element - setting value to complex object values', async function(test, options) {

        var tpElem,
            value;

        tpElem = TP.byId('input_text', windowContext);

        //  RegExp
        await tpElem.set('value', testData.at('RegExp'));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, TP.str(testData.at('RegExp')));

        //  Date
        await tpElem.set('value', testData.at('Date'));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, TP.str(testData.at('Date')));

        //  Array
        await tpElem.set('value', testData.at('Array'));
        value = tpElem.get('value');
        //  <input type="text"/> is both single-valued and scalar-valued
        test.assert.isEqualTo(value, '1');

        //  Object
        await tpElem.set('value', testData.at('Object'));
        value = tpElem.get('value');
        //  <input type="text"/> is both single-valued and scalar-valued
        test.assert.isEqualTo(value, 'bar');

        //  TP.core.Hash
        await tpElem.set('value', testData.at('TP.core.Hash'));
        value = tpElem.get('value');
        //  <input type="text"/> is both single-valued and scalar-valued
        test.assert.isEqualTo(value, 'bar');
    });

    //  ---

    this.it('input type="text" element - setting value to markup', async function(test, options) {

        var tpElem,
            value;

        tpElem = TP.byId('input_text', windowContext);

        //  XMLDocument
        await tpElem.set('value', TP.nodeCloneNode(testData.at('XMLDocument')));
        value = tpElem.get('value');
        //  <input type="text"/> is both single-valued and scalar-valued
        test.assert.isEqualTo(value, 'Hi there<boo><goo/></boo><moo/>');

        //  XMLElement
        await tpElem.set('value', TP.nodeCloneNode(testData.at('XMLElement')));
        value = tpElem.get('value');
        //  <input type="text"/> is both single-valued and scalar-valued
        test.assert.isEqualTo(value, 'bar');

        //  AttributeNode
        await tpElem.set('value', TP.nodeCloneNode(testData.at('AttributeNode')));
        value = tpElem.get('value');
        //  <input type="text"/> is both single-valued and scalar-valued
        test.assert.isEqualTo(value, 'bar');

        //  TextNode
        await tpElem.set('value', TP.nodeCloneNode(testData.at('TextNode')));
        value = tpElem.get('value');
        //  <input type="text"/> is both single-valued and scalar-valued
        test.assert.isEqualTo(value, 'foo');

        //  CDATASectionNode
        await tpElem.set('value', TP.nodeCloneNode(testData.at('CDATASectionNode')));
        value = tpElem.get('value');
        //  <input type="text"/> is both single-valued and scalar-valued
        test.assert.isEqualTo(value, 'foo');

        //  PINode
        await tpElem.set('value', TP.nodeCloneNode(testData.at('PINode')));
        value = tpElem.get('value');
        //  <input type="text"/> is both single-valued and scalar-valued
        test.assert.isEqualTo(value, 'bar');

        //  CommentNode
        await tpElem.set('value', TP.nodeCloneNode(testData.at('CommentNode')));
        value = tpElem.get('value');
        //  <input type="text"/> is both single-valued and scalar-valued
        test.assert.isEqualTo(value, 'foo');

        //  DocumentFragmentNode
        await tpElem.set('value', TP.nodeCloneNode(testData.at('DocumentFragmentNode')));
        value = tpElem.get('value');
        //  <input type="text"/> is both single-valued and scalar-valued
        test.assert.isEqualTo(value, 'foo, bar');

        //  NodeList
        await tpElem.set('value', testData.at('NodeList'));
        value = tpElem.get('value');
        //  <input type="text"/> is both single-valued and scalar-valued
        test.assert.isEqualTo(value, 'Hi there');

        //  NamedNodeMap
        await tpElem.set('value', testData.at('NamedNodeMap'));
        value = tpElem.get('value');
        //  <input type="text"/> is both single-valued and scalar-valued
        test.assert.isEqualTo(value, 'baz');
    });

    //  ---

    this.it('textarea element - setting value to scalar values', async function(test, options) {

        var tpElem,
            value;

        tpElem = TP.byId('textarea', windowContext);

        //  undefined
        await tpElem.set('value', testData.at(TP.UNDEF));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, TP.str(''));

        //  null
        await tpElem.set('value', testData.at(TP.NULL));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, TP.str(''));

        //  String
        await tpElem.set('value', testData.at('String'));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, TP.str(testData.at('String')));

        //  Number
        await tpElem.set('value', testData.at('Number'));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, TP.str(testData.at('Number')));

        //  Boolean
        await tpElem.set('value', testData.at('Boolean'));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, TP.str(testData.at('Boolean')));
    });

    //  ---

    this.it('textarea element - setting value to complex object values', async function(test, options) {

        var tpElem,
            value;

        tpElem = TP.byId('textarea', windowContext);

        //  RegExp
        await tpElem.set('value', testData.at('RegExp'));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, TP.str(testData.at('RegExp')));

        //  Date
        await tpElem.set('value', testData.at('Date'));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, TP.str(testData.at('Date')));

        //  Array
        await tpElem.set('value', testData.at('Array'));
        value = tpElem.get('value');
        //  <input type="text"/> is both single-valued and scalar-valued
        test.assert.isEqualTo(value, '1');

        //  Object
        await tpElem.set('value', testData.at('Object'));
        value = tpElem.get('value');
        //  <input type="text"/> is both single-valued and scalar-valued
        test.assert.isEqualTo(value, 'bar');

        //  TP.core.Hash
        await tpElem.set('value', testData.at('TP.core.Hash'));
        value = tpElem.get('value');
        //  <input type="text"/> is both single-valued and scalar-valued
        test.assert.isEqualTo(value, 'bar');
    });

    //  ---

    this.it('textarea element - setting value to markup', async function(test, options) {

        var tpElem,
            value;

        tpElem = TP.byId('textarea', windowContext);

        //  XMLDocument
        await tpElem.set('value', TP.nodeCloneNode(testData.at('XMLDocument')));
        value = tpElem.get('value');
        //  <input type="text"/> is both single-valued and scalar-valued
        test.assert.isEqualTo(value, 'Hi there<boo><goo/></boo><moo/>');

        //  XMLElement
        await tpElem.set('value', TP.nodeCloneNode(testData.at('XMLElement')));
        value = tpElem.get('value');
        //  <input type="text"/> is both single-valued and scalar-valued
        test.assert.isEqualTo(value, 'bar');

        //  AttributeNode
        await tpElem.set('value', TP.nodeCloneNode(testData.at('AttributeNode')));
        value = tpElem.get('value');
        //  <input type="text"/> is both single-valued and scalar-valued
        test.assert.isEqualTo(value, 'bar');

        //  TextNode
        await tpElem.set('value', TP.nodeCloneNode(testData.at('TextNode')));
        value = tpElem.get('value');
        //  <input type="text"/> is both single-valued and scalar-valued
        test.assert.isEqualTo(value, 'foo');

        //  CDATASectionNode
        await tpElem.set('value', TP.nodeCloneNode(testData.at('CDATASectionNode')));
        value = tpElem.get('value');
        //  <input type="text"/> is both single-valued and scalar-valued
        test.assert.isEqualTo(value, 'foo');

        //  PINode
        await tpElem.set('value', TP.nodeCloneNode(testData.at('PINode')));
        value = tpElem.get('value');
        //  <input type="text"/> is both single-valued and scalar-valued
        test.assert.isEqualTo(value, 'bar');

        //  CommentNode
        await tpElem.set('value', TP.nodeCloneNode(testData.at('CommentNode')));
        value = tpElem.get('value');
        //  <input type="text"/> is both single-valued and scalar-valued
        test.assert.isEqualTo(value, 'foo');

        //  DocumentFragmentNode
        await tpElem.set('value', TP.nodeCloneNode(testData.at('DocumentFragmentNode')));
        value = tpElem.get('value');
        //  <input type="text"/> is both single-valued and scalar-valued
        test.assert.isEqualTo(value, 'foo, bar');

        //  NodeList
        await tpElem.set('value', testData.at('NodeList'));
        value = tpElem.get('value');
        //  <input type="text"/> is both single-valued and scalar-valued
        test.assert.isEqualTo(value, 'Hi there');

        //  NamedNodeMap
        await tpElem.set('value', testData.at('NamedNodeMap'));
        value = tpElem.get('value');
        //  <input type="text"/> is both single-valued and scalar-valued
        test.assert.isEqualTo(value, 'baz');
    });

    //  ---

    this.it('select element - setting value to scalar values', async function(test, options) {

        var tpElem,
            value;

        //  Per the markup, valid values for this control are 'foo', 'bar', and
        //  'baz'.

        tpElem = TP.byId('select_single', windowContext);

        //  undefined
        await tpElem.set('value', testData.at(TP.UNDEF));
        value = tpElem.get('value');
        test.assert.isNull(value);

        //  null
        await tpElem.set('value', testData.at(TP.NULL));
        value = tpElem.get('value');
        test.assert.isNull(value);

        //  String
        await tpElem.set('value', testData.at('String'));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, TP.str(testData.at('String')));

        //  Number
        await tpElem.set('value', testData.at('Number'));
        value = tpElem.get('value');
        test.assert.isNull(value);

        //  Boolean
        await tpElem.set('value', testData.at('Boolean'));
        value = tpElem.get('value');
        test.assert.isNull(value);
    });

    //  ---

    this.it('select element - setting value to complex object values', async function(test, options) {

        var tpElem,
            value;

        //  Per the markup, valid values for this control are 'foo', 'bar', and
        //  'baz'.

        tpElem = TP.byId('select_single', windowContext);

        //  RegExp
        await tpElem.set('value', testData.at('RegExp'));
        value = tpElem.get('value');
        test.assert.isNull(value);

        //  Date
        await tpElem.set('value', testData.at('Date'));
        value = tpElem.get('value');
        test.assert.isNull(value);

        //  Array
        await tpElem.set('value', TP.ac('foo', 'bar', 'baz'));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, 'foo');

        //  Object
        await tpElem.set('value', {foo: 'baz'});
        value = tpElem.get('value');
        test.assert.isEqualTo(value, 'baz');

        //  TP.core.Hash
        await tpElem.set('value', TP.hc('foo', 'bar'));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, 'bar');
    });

    //  ---

    this.it('select element - setting value to markup', async function(test, options) {

        var tpElem,
            value;

        tpElem = TP.byId('select_single', windowContext);

        //  XMLDocument
        await tpElem.set('value', TP.nodeCloneNode(testData.at('XMLDocument')));
        value = tpElem.get('value');
        test.assert.isNull(value);

        //  XMLElement
        await tpElem.set('value', TP.nodeCloneNode(testData.at('XMLElement')));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, 'bar');

        //  AttributeNode
        await tpElem.set('value', TP.nodeCloneNode(testData.at('AttributeNode')));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, 'bar');

        //  TextNode
        await tpElem.set('value', TP.nodeCloneNode(testData.at('TextNode')));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, 'foo');

        //  CDATASectionNode
        await tpElem.set('value', TP.nodeCloneNode(testData.at('CDATASectionNode')));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, 'foo');

        //  PINode
        await tpElem.set('value', TP.nodeCloneNode(testData.at('PINode')));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, 'bar');

        //  CommentNode
        await tpElem.set('value', TP.nodeCloneNode(testData.at('CommentNode')));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, 'foo');

        //  DocumentFragmentNode
        await tpElem.set('value', TP.nodeCloneNode(testData.at('DocumentFragmentNode')));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, 'foo');

        //  NodeList
        await tpElem.set('value', testData.at('NodeList'));
        value = tpElem.get('value');
        test.assert.isNull(value);

        //  NamedNodeMap
        await tpElem.set('value', testData.at('NamedNodeMap'));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, 'baz');
    });

    //  ---

    this.it('select (multiple) element - setting value to scalar values', async function(test, options) {

        var tpElem,
            value;

        //  Per the markup, valid values for this control are 'foo', 'bar', and
        //  'baz'.

        tpElem = TP.byId('select_multiple', windowContext);

        //  undefined
        await tpElem.set('value', testData.at(TP.UNDEF));
        value = tpElem.get('value');
        test.assert.isEmpty(value);

        //  null
        await tpElem.set('value', testData.at(TP.NULL));
        value = tpElem.get('value');
        test.assert.isEmpty(value);

        //  String
        await tpElem.set('value', testData.at('String'));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, TP.ac('bar'));

        //  String (multiple)
        await tpElem.set('value', 'foo;baz');
        value = tpElem.get('value');
        test.assert.isEqualTo(value, TP.ac('foo', 'baz'));

        //  Number
        await tpElem.set('value', testData.at('Number'));
        value = tpElem.get('value');
        test.assert.isEmpty(value);

        //  Boolean
        await tpElem.set('value', testData.at('Boolean'));
        value = tpElem.get('value');
        test.assert.isEmpty(value);
    });

    //  ---

    this.it('select (multiple) element - setting value to complex object values', async function(test, options) {

        var tpElem,
            value;

        //  Per the markup, valid values for this control are 'foo', 'bar', and
        //  'baz'.

        tpElem = TP.byId('select_multiple', windowContext);

        //  RegExp
        await tpElem.set('value', testData.at('RegExp'));
        value = tpElem.get('value');
        test.assert.isEmpty(value);

        //  Date
        await tpElem.set('value', testData.at('Date'));
        value = tpElem.get('value');
        test.assert.isEmpty(value);

        //  Array
        await tpElem.set('value', TP.ac('foo', 'bar', 'baz'));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, TP.ac('foo', 'bar', 'baz'));

        //  Object
        await tpElem.set('value', {foo: 'baz'});
        value = tpElem.get('value');
        test.assert.isEqualTo(value, TP.ac('baz'));

        //  TP.core.Hash
        await tpElem.set('value', TP.hc('foo', 'bar'));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, TP.ac('bar'));
    });

    //  ---

    this.it('select (multiple) element - setting value to markup', async function(test, options) {

        var tpElem,
            value;

        tpElem = TP.byId('select_multiple', windowContext);

        //  XMLDocument
        await tpElem.set('value', TP.nodeCloneNode(testData.at('XMLDocument')));
        value = tpElem.get('value');
        test.assert.isEmpty(value);

        //  XMLElement
        await tpElem.set('value', TP.nodeCloneNode(testData.at('XMLElement')));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, TP.ac('bar'));

        //  AttributeNode
        await tpElem.set('value', TP.nodeCloneNode(testData.at('AttributeNode')));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, TP.ac('bar'));

        //  TextNode
        await tpElem.set('value', TP.nodeCloneNode(testData.at('TextNode')));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, TP.ac('foo'));

        //  CDATASectionNode
        await tpElem.set('value', TP.nodeCloneNode(testData.at('CDATASectionNode')));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, TP.ac('foo'));

        //  PINode
        await tpElem.set('value', TP.nodeCloneNode(testData.at('PINode')));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, TP.ac('bar'));

        //  CommentNode
        await tpElem.set('value', TP.nodeCloneNode(testData.at('CommentNode')));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, TP.ac('foo'));

        //  DocumentFragmentNode
        await tpElem.set('value', TP.nodeCloneNode(testData.at('DocumentFragmentNode')));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, TP.ac('foo', 'bar'));

        //  NodeList
        await tpElem.set('value', testData.at('NodeList'));
        value = tpElem.get('value');
        test.assert.isEmpty(value);

        //  NamedNodeMap
        await tpElem.set('value', testData.at('NamedNodeMap'));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, TP.ac('baz'));
    });

    //  ---

    this.it('input type="radio" element - setting value to scalar values', async function(test, options) {

        var tpElem,
            value;

        //  Per the markup, valid values for this control are 'foo', 'bar', and
        //  'baz'.

        tpElem = TP.byId('input_radio_3', windowContext);

        //  undefined
        await tpElem.set('value', testData.at(TP.UNDEF));
        value = tpElem.get('value');
        test.assert.isNull(value);

        //  null
        await tpElem.set('value', testData.at(TP.NULL));
        value = tpElem.get('value');
        test.assert.isNull(value);

        //  String
        await tpElem.set('value', testData.at('String'));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, TP.str(testData.at('String')));

        //  Number
        await tpElem.set('value', testData.at('Number'));
        value = tpElem.get('value');
        test.assert.isNull(value);

        //  Boolean
        await tpElem.set('value', testData.at('Boolean'));
        value = tpElem.get('value');
        test.assert.isNull(value);
    });

    //  ---

    this.it('input type="radio" element - setting value to complex object values', async function(test, options) {

        var tpElem,
            value;

        //  Per the markup, valid values for this control are 'foo', 'bar', and
        //  'baz'.

        tpElem = TP.byId('input_radio_3', windowContext);

        //  RegExp
        await tpElem.set('value', testData.at('RegExp'));
        value = tpElem.get('value');
        test.assert.isNull(value);

        //  Date
        await tpElem.set('value', testData.at('Date'));
        value = tpElem.get('value');
        test.assert.isNull(value);

        //  Array
        await tpElem.set('value', TP.ac('foo', 'bar', 'baz'));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, 'foo');

        //  Object
        await tpElem.set('value', {foo: 'baz'});
        value = tpElem.get('value');
        test.assert.isEqualTo(value, 'baz');

        //  TP.core.Hash
        await tpElem.set('value', TP.hc('foo', 'bar'));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, 'bar');
    });

    //  ---

    this.it('input type="radio" element - setting value to markup', async function(test, options) {

        var tpElem,
            value;

        tpElem = TP.byId('input_radio_3', windowContext);

        //  XMLDocument
        await tpElem.set('value', TP.nodeCloneNode(testData.at('XMLDocument')));
        value = tpElem.get('value');
        test.assert.isNull(value);

        //  XMLElement
        await tpElem.set('value', TP.nodeCloneNode(testData.at('XMLElement')));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, 'bar');

        //  AttributeNode
        await tpElem.set('value', TP.nodeCloneNode(testData.at('AttributeNode')));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, 'bar');

        //  TextNode
        await tpElem.set('value', TP.nodeCloneNode(testData.at('TextNode')));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, 'foo');

        //  CDATASectionNode
        await tpElem.set('value', TP.nodeCloneNode(testData.at('CDATASectionNode')));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, 'foo');

        //  PINode
        await tpElem.set('value', TP.nodeCloneNode(testData.at('PINode')));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, 'bar');

        //  CommentNode
        await tpElem.set('value', TP.nodeCloneNode(testData.at('CommentNode')));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, 'foo');

        //  DocumentFragmentNode
        await tpElem.set('value', TP.nodeCloneNode(testData.at('DocumentFragmentNode')));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, 'foo');

        //  NodeList
        await tpElem.set('value', testData.at('NodeList'));
        value = tpElem.get('value');
        test.assert.isNull(value);

        //  NamedNodeMap
        await tpElem.set('value', testData.at('NamedNodeMap'));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, 'baz');
    });

    //  ---

    this.it('input type="checkbox" element - setting value to scalar values', async function(test, options) {

        var tpElem,
            value;

        //  Per the markup, valid values for this control are 'foo', 'bar', and
        //  'baz'.

        tpElem = TP.byId('input_checkbox_3', windowContext);
        await tpElem.deselectAll();

        //  undefined
        await tpElem.set('value', testData.at(TP.UNDEF));
        value = tpElem.get('value');
        test.assert.isEmpty(value);

        //  null
        await tpElem.set('value', testData.at(TP.NULL));
        value = tpElem.get('value');
        test.assert.isEmpty(value);

        //  String
        await tpElem.set('value', testData.at('String'));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, TP.ac('bar'));

        //  reset
        await tpElem.deselectAll();

        //  String (multiple)
        await tpElem.set('value', 'foo;baz');
        value = tpElem.get('value');
        test.assert.isEqualTo(value, TP.ac('foo', 'baz'));

        //  reset
        await tpElem.deselectAll();

        //  Number
        await tpElem.set('value', testData.at('Number'));
        value = tpElem.get('value');
        test.assert.isEmpty(value);

        //  Boolean
        await tpElem.set('value', testData.at('Boolean'));
        value = tpElem.get('value');
        test.assert.isEmpty(value);
    });

    //  ---

    this.it('input type="checkbox" element - setting value to complex object values', async function(test, options) {

        var tpElem,
            value;

        //  Per the markup, valid values for this control are 'foo', 'bar', and
        //  'baz'.

        tpElem = TP.byId('input_checkbox_3', windowContext);
        await tpElem.deselectAll();

        //  RegExp
        await tpElem.set('value', testData.at('RegExp'));
        value = tpElem.get('value');
        test.assert.isEmpty(value);

        //  Date
        await tpElem.set('value', testData.at('Date'));
        value = tpElem.get('value');
        test.assert.isEmpty(value);

        //  Array
        await tpElem.set('value', TP.ac('foo', 'bar', 'baz'));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, TP.ac('foo', 'bar', 'baz'));

        //  reset
        await tpElem.deselectAll();

        //  Object
        await tpElem.set('value', {foo: 'baz'});
        value = tpElem.get('value');
        test.assert.isEqualTo(value, TP.ac('baz'));

        //  reset
        await tpElem.deselectAll();

        //  TP.core.Hash
        await tpElem.set('value', TP.hc('foo', 'bar'));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, TP.ac('bar'));
    });

    //  ---

    this.it('input type="checkbox" element - setting value to markup', async function(test, options) {

        var tpElem,
            value;

        tpElem = TP.byId('input_checkbox_3', windowContext);
        await tpElem.deselectAll();

        //  XMLDocument
        await tpElem.set('value', TP.nodeCloneNode(testData.at('XMLDocument')));
        value = tpElem.get('value');
        test.assert.isEmpty(value);

        //  XMLElement
        await tpElem.set('value', TP.nodeCloneNode(testData.at('XMLElement')));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, TP.ac('bar'));

        //  reset
        await tpElem.deselectAll();

        //  AttributeNode
        await tpElem.set('value', TP.nodeCloneNode(testData.at('AttributeNode')));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, TP.ac('bar'));

        //  reset
        await tpElem.deselectAll();

        //  TextNode
        await tpElem.set('value', TP.nodeCloneNode(testData.at('TextNode')));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, TP.ac('foo'));

        //  reset
        await tpElem.deselectAll();

        //  CDATASectionNode
        await tpElem.set('value', TP.nodeCloneNode(testData.at('CDATASectionNode')));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, TP.ac('foo'));

        //  reset
        await tpElem.deselectAll();

        //  PINode
        await tpElem.set('value', TP.nodeCloneNode(testData.at('PINode')));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, TP.ac('bar'));

        //  reset
        await tpElem.deselectAll();

        //  CommentNode
        await tpElem.set('value', TP.nodeCloneNode(testData.at('CommentNode')));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, TP.ac('foo'));

        //  reset
        await tpElem.deselectAll();

        //  DocumentFragmentNode
        await tpElem.set('value', TP.nodeCloneNode(testData.at('DocumentFragmentNode')));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, TP.ac('foo', 'bar'));

        //  NodeList
        await tpElem.set('value', testData.at('NodeList'));
        value = tpElem.get('value');
        test.assert.isEmpty(value);

        //  NamedNodeMap
        await tpElem.set('value', testData.at('NamedNodeMap'));
        value = tpElem.get('value');
        test.assert.isEqualTo(value, TP.ac('baz'));
    });
});

//  ------------------------------------------------------------------------

TP.html.XMLNS.Type.describe('html: selection management of standard elements',
function() {

    var windowContext;

    this.before(
        async function(suite, options) {
            var testDataLoc,
                loadURI;

            TP.$$setupCommonObjectValues();

            testDataLoc = '~lib_test/src/html/HTMLContent.xhtml';
            loadURI = TP.uc(testDataLoc);

            windowContext = this.getDriver().get('windowContext');

            await this.getDriver().setLocation(loadURI);
        });

    //  ---

    this.it('select element - selection management', async function(test, options) {

        var tpElem;

        //  Per the markup, valid values for this control are 'foo', 'bar', and
        //  'baz'.

        tpElem = TP.byId('select_single', windowContext);

        //  ---

        //  allowsMultiples

        //  by default, select elements don't allow multiples
        test.assert.isFalse(tpElem.allowsMultiples());

        //  ---

        //  addSelection

        //  (property defaults to 'value')
        await tpElem.addSelection('baz');
        test.assert.isEqualTo(tpElem.getNativeNode().selectedIndex, 2);

        //  'value' property
        await tpElem.addSelection('bar', 'value');
        test.assert.isEqualTo(tpElem.getNativeNode().selectedIndex, 1);

        //  'label' property
        await tpElem.addSelection('Dog', 'label');
        test.assert.isEqualTo(tpElem.getNativeNode().selectedIndex, 0);

        //  'id' property
        await tpElem.addSelection('select_single_3', 'id');
        test.assert.isEqualTo(tpElem.getNativeNode().selectedIndex, 2);

        //  'index' property
        await tpElem.addSelection(1, 'index');
        test.assert.isEqualTo(tpElem.getNativeNode().selectedIndex, 1);

        //  ---

        //  removeSelection

        //  (property defaults to 'value')
        tpElem.getNativeNode().selectedIndex = 1;
        await tpElem.removeSelection('baz');
        test.assert.isEqualTo(tpElem.getNativeNode().selectedIndex, 1);

        tpElem.getNativeNode().selectedIndex = 2;
        await tpElem.removeSelection('baz');
        test.assert.isEqualTo(tpElem.getNativeNode().selectedIndex, -1);

        //  'value' property
        tpElem.getNativeNode().selectedIndex = 2;
        await tpElem.removeSelection('bar', 'value');
        test.assert.isEqualTo(tpElem.getNativeNode().selectedIndex, 2);

        tpElem.getNativeNode().selectedIndex = 1;
        await tpElem.removeSelection('bar', 'value');
        test.assert.isEqualTo(tpElem.getNativeNode().selectedIndex, -1);

        //  'label' property
        tpElem.getNativeNode().selectedIndex = 1;
        await tpElem.removeSelection('Dog', 'label');
        test.assert.isEqualTo(tpElem.getNativeNode().selectedIndex, 1);

        tpElem.getNativeNode().selectedIndex = 0;
        await tpElem.removeSelection('Dog', 'label');
        test.assert.isEqualTo(tpElem.getNativeNode().selectedIndex, -1);

        //  'id' property
        tpElem.getNativeNode().selectedIndex = 1;
        await tpElem.removeSelection('select_single_3', 'id');
        test.assert.isEqualTo(tpElem.getNativeNode().selectedIndex, 1);

        tpElem.getNativeNode().selectedIndex = 2;
        await tpElem.removeSelection('select_single_3', 'id');
        test.assert.isEqualTo(tpElem.getNativeNode().selectedIndex, -1);

        //  'index' property
        tpElem.getNativeNode().selectedIndex = 2;
        await tpElem.removeSelection(1, 'index');
        test.assert.isEqualTo(tpElem.getNativeNode().selectedIndex, 2);

        tpElem.getNativeNode().selectedIndex = 1;
        await tpElem.removeSelection(1, 'index');
        test.assert.isEqualTo(tpElem.getNativeNode().selectedIndex, -1);
    });

    //  ---

    this.it('select (multiple) element - selection management', async function(test, options) {

        var tpElem,
            getSelectedIndices;

        //  Per the markup, valid values for this control are 'foo', 'bar', and
        //  'baz'.

        tpElem = TP.byId('select_multiple', windowContext);

        getSelectedIndices = function(aTPElem) {
            var natElem,

                selectedOptions,
                i,
                indices;

            natElem = TP.unwrap(aTPElem);

            //  Newer browsers have this property, but Headless doesn't...
            if (natElem.selectedOptions) {
                selectedOptions = natElem.selectedOptions;
            } else {
                selectedOptions = aTPElem.getValueElements().collect(
                                        function(valueTPElem) {
                                            var valueElem;

                                            valueElem = TP.unwrap(valueTPElem);
                                            if (valueElem.selected) {
                                                return valueElem;
                                            }
                                        });

                //  Removes nulls and undefineds
                selectedOptions.compact();
            }

            indices = TP.ac();
            for (i = 0; i < selectedOptions.length; i++) {
                indices.push(selectedOptions[i].index);
            }

            return indices;
        };

        //  ---

        //  allowsMultiples

        //  when configured with 'multiple="multiple"', select elements allow
        //  multiples
        test.assert.isTrue(tpElem.allowsMultiples());

        //  ---

        //  addSelection (and deselectAll)

        //  (property defaults to 'value')
        await tpElem.deselectAll();
        await tpElem.addSelection(TP.ac('bar', 'baz'));
        test.assert.isEqualTo(getSelectedIndices(tpElem), TP.ac(1, 2));

        //  'value' property
        await tpElem.deselectAll();
        await tpElem.addSelection(TP.ac('foo', 'bar'), 'value');
        test.assert.isEqualTo(getSelectedIndices(tpElem), TP.ac(0, 1));

        //  'label' property
        await tpElem.deselectAll();
        await tpElem.addSelection(TP.ac('Red', 'Yellow'), 'label');
        test.assert.isEqualTo(getSelectedIndices(tpElem), TP.ac(0, 2));

        //  'id' property
        await tpElem.deselectAll();
        await tpElem.addSelection(TP.ac('select_multiple_1', 'select_multiple_2'), 'id');
        test.assert.isEqualTo(getSelectedIndices(tpElem), TP.ac(0, 1));

        //  'index' property
        await tpElem.deselectAll();
        await tpElem.addSelection(TP.ac(1, 2), 'index');
        test.assert.isEqualTo(getSelectedIndices(tpElem), TP.ac(1, 2));

        //  ---

        //  removeSelection (and deselectAll)

        //  (property defaults to 'value')
        await tpElem.deselectAll();
        await tpElem.addSelection(TP.ac('foo', 'bar'));
        await tpElem.removeSelection('baz');
        test.assert.isEqualTo(getSelectedIndices(tpElem), TP.ac(0, 1));

        await tpElem.deselectAll();
        await tpElem.addSelection(TP.ac('bar', 'baz'));
        await tpElem.removeSelection('baz');
        test.assert.isEqualTo(getSelectedIndices(tpElem), TP.ac(1));

        //  'value' property
        await tpElem.deselectAll();
        await tpElem.addSelection(TP.ac('foo', 'baz'));
        await tpElem.removeSelection('bar', 'value');
        test.assert.isEqualTo(getSelectedIndices(tpElem), TP.ac(0, 2));

        await tpElem.deselectAll();
        await tpElem.addSelection(TP.ac('bar', 'baz'));
        await tpElem.removeSelection('bar', 'value');
        test.assert.isEqualTo(getSelectedIndices(tpElem), TP.ac(2));

        //  'label' property
        await tpElem.deselectAll();
        await tpElem.addSelection(TP.ac('Red', 'Yellow'), 'label');
        await tpElem.removeSelection('Blue', 'label');
        test.assert.isEqualTo(getSelectedIndices(tpElem), TP.ac(0, 2));

        await tpElem.deselectAll();
        await tpElem.addSelection(TP.ac('Red', 'Blue'), 'label');
        await tpElem.removeSelection('Blue', 'label');
        test.assert.isEqualTo(getSelectedIndices(tpElem), TP.ac(0));

        //  'id' property
        await tpElem.deselectAll();
        await tpElem.addSelection(TP.ac('select_multiple_1', 'select_multiple_2'), 'id');
        await tpElem.removeSelection('select_multiple_3', 'id');
        test.assert.isEqualTo(getSelectedIndices(tpElem), TP.ac(0, 1));

        await tpElem.deselectAll();
        await tpElem.addSelection(TP.ac('select_multiple_1', 'select_multiple_3'), 'id');
        await tpElem.removeSelection('select_multiple_3', 'id');
        test.assert.isEqualTo(getSelectedIndices(tpElem), TP.ac(0));

        //  'index' property
        await tpElem.deselectAll();
        await tpElem.addSelection(TP.ac(1, 2), 'index');
        await tpElem.removeSelection(0, 'index');
        test.assert.isEqualTo(getSelectedIndices(tpElem), TP.ac(1, 2));

        await tpElem.deselectAll();
        await tpElem.addSelection(TP.ac(0, 1), 'index');
        await tpElem.removeSelection(0, 'index');
        test.assert.isEqualTo(getSelectedIndices(tpElem), TP.ac(1));

        //  ---

        //  selectAll

        await tpElem.selectAll();
        test.assert.isEqualTo(getSelectedIndices(tpElem), TP.ac(0, 1, 2));

        //  ---

        //  select (and deselectAll)

        //  (property defaults to 'value')
        await tpElem.deselectAll();
        await tpElem.select('bar');
        test.assert.isEqualTo(getSelectedIndices(tpElem), TP.ac(1));
        await tpElem.select('baz');
        test.assert.isEqualTo(getSelectedIndices(tpElem), TP.ac(1, 2));

        await tpElem.deselectAll();
        await tpElem.select(TP.ac('foo', 'baz'));
        test.assert.isEqualTo(getSelectedIndices(tpElem), TP.ac(0, 2));

        //  ---

        //  select (with RegExp)

        await tpElem.deselectAll();
        await tpElem.select(/ba/);
        test.assert.isEqualTo(getSelectedIndices(tpElem), TP.ac(1, 2));

        //  ---

        //  deselect (and selectAll)

        //  (property defaults to 'value')
        await tpElem.selectAll();
        await tpElem.deselect('bar');
        test.assert.isEqualTo(getSelectedIndices(tpElem), TP.ac(0, 2));
        await tpElem.deselect('baz');
        test.assert.isEqualTo(getSelectedIndices(tpElem), TP.ac(0));

        await tpElem.selectAll();
        await tpElem.deselect(TP.ac('foo', 'baz'));
        test.assert.isEqualTo(getSelectedIndices(tpElem), TP.ac(1));

        //  ---

        //  deselect (with RegExp)

        await tpElem.selectAll();
        await tpElem.deselect(/ba/);
        test.assert.isEqualTo(getSelectedIndices(tpElem), TP.ac(0));
    });

    //  ---

    this.it('input type="radio" element - selection management', async function(test, options) {

        var tpElem;

        //  Per the markup, valid values for this control are 'foo', 'bar', and
        //  'baz'.

        tpElem = TP.byId('input_radio_3', windowContext);

        //  ---

        //  allowsMultiples

        //  radio button elements don't allow multiples
        test.assert.isFalse(tpElem.allowsMultiples());

        //  ---

        //  addSelection

        //  (property defaults to 'value')
        await tpElem.addSelection('baz');
        test.assert.isFalse(TP.byId('input_radio_1', windowContext).isSelected());
        test.assert.isFalse(TP.byId('input_radio_2', windowContext).isSelected());
        test.assert.isTrue(TP.byId('input_radio_3', windowContext).isSelected());

        //  'value' property
        await tpElem.addSelection('bar', 'value');
        test.assert.isFalse(TP.byId('input_radio_1', windowContext).isSelected());
        test.assert.isTrue(TP.byId('input_radio_2', windowContext).isSelected());
        test.assert.isFalse(TP.byId('input_radio_3', windowContext).isSelected());

        //  'label' property
        await tpElem.addSelection('Dog', 'label');
        test.assert.isTrue(TP.byId('input_radio_1', windowContext).isSelected());
        test.assert.isFalse(TP.byId('input_radio_2', windowContext).isSelected());
        test.assert.isFalse(TP.byId('input_radio_3', windowContext).isSelected());

        //  'id' property
        await tpElem.addSelection('input_radio_3', 'id');
        test.assert.isFalse(TP.byId('input_radio_1', windowContext).isSelected());
        test.assert.isFalse(TP.byId('input_radio_2', windowContext).isSelected());
        test.assert.isTrue(TP.byId('input_radio_3', windowContext).isSelected());

        //  'index' property
        await tpElem.addSelection(1, 'index');
        test.assert.isFalse(TP.byId('input_radio_1', windowContext).isSelected());
        test.assert.isTrue(TP.byId('input_radio_2', windowContext).isSelected());
        test.assert.isFalse(TP.byId('input_radio_3', windowContext).isSelected());

        //  ---

        await tpElem.addSelection('bar');

        //  removeSelection

        //  (property defaults to 'value')
        TP.byId('input_radio_2', windowContext, false).checked = true;
        await tpElem.removeSelection('baz');
        test.assert.isFalse(TP.byId('input_radio_1', windowContext).isSelected());
        test.assert.isTrue(TP.byId('input_radio_2', windowContext).isSelected());
        test.assert.isFalse(TP.byId('input_radio_3', windowContext).isSelected());

        TP.byId('input_radio_3', windowContext, false).checked = true;
        await tpElem.removeSelection('baz');
        test.assert.isFalse(TP.byId('input_radio_3', windowContext).isSelected());

        //  'value' property
        TP.byId('input_radio_3', windowContext, false).checked = true;
        await tpElem.removeSelection('bar', 'value');
        test.assert.isFalse(TP.byId('input_radio_1', windowContext).isSelected());
        test.assert.isFalse(TP.byId('input_radio_2', windowContext).isSelected());
        test.assert.isTrue(TP.byId('input_radio_3', windowContext).isSelected());

        TP.byId('input_radio_2', windowContext, false).checked = true;
        await tpElem.removeSelection('bar', 'value');
        test.assert.isFalse(TP.byId('input_radio_2', windowContext).isSelected());

        //  'label' property
        TP.byId('input_radio_2', windowContext, false).checked = true;
        await tpElem.removeSelection('Dog', 'label');
        test.assert.isFalse(TP.byId('input_radio_1', windowContext).isSelected());
        test.assert.isTrue(TP.byId('input_radio_2', windowContext).isSelected());
        test.assert.isFalse(TP.byId('input_radio_3', windowContext).isSelected());

        TP.byId('input_radio_1', windowContext, false).checked = true;
        await tpElem.removeSelection('Dog', 'label');
        test.assert.isFalse(TP.byId('input_radio_1', windowContext).isSelected());

        //  'id' property
        TP.byId('input_radio_2', windowContext, false).checked = true;
        await tpElem.removeSelection('input_radio_3', 'id');
        test.assert.isFalse(TP.byId('input_radio_1', windowContext).isSelected());
        test.assert.isTrue(TP.byId('input_radio_2', windowContext).isSelected());
        test.assert.isFalse(TP.byId('input_radio_3', windowContext).isSelected());

        TP.byId('input_radio_3', windowContext, false).checked = true;
        await tpElem.removeSelection('input_radio_3', 'id');
        test.assert.isFalse(TP.byId('input_radio_3', windowContext).isSelected());

        //  'index' property
        TP.byId('input_radio_3', windowContext, false).checked = true;
        await tpElem.removeSelection(1, 'index');
        test.assert.isFalse(TP.byId('input_radio_1', windowContext).isSelected());
        test.assert.isFalse(TP.byId('input_radio_2', windowContext).isSelected());
        test.assert.isTrue(TP.byId('input_radio_3', windowContext).isSelected());

        TP.byId('input_radio_2', windowContext, false).checked = true;
        await tpElem.removeSelection(1, 'index');
        test.assert.isFalse(TP.byId('input_radio_2', windowContext).isSelected());

        //  ---

        //  select

        //  (property defaults to 'value')
        await tpElem.select('bar');
        test.assert.isFalse(TP.byId('input_radio_1', windowContext).isSelected());
        test.assert.isTrue(TP.byId('input_radio_2', windowContext).isSelected());
        test.assert.isFalse(TP.byId('input_radio_3', windowContext).isSelected());

        await tpElem.select('baz');
        test.assert.isFalse(TP.byId('input_radio_1', windowContext).isSelected());
        test.assert.isFalse(TP.byId('input_radio_2', windowContext).isSelected());
        test.assert.isTrue(TP.byId('input_radio_3', windowContext).isSelected());
    });

    //  ---

    this.it('input type="checkbox" element - selection management', async function(test, options) {

        var tpElem,
            getSelectedIndices;

        //  Per the markup, valid values for this control are 'foo', 'bar', and
        //  'baz'.

        tpElem = TP.byId('input_checkbox_3', windowContext);

        getSelectedIndices = function(aTPElem) {
            var checkboxIndices;

            checkboxIndices = aTPElem.getValueElements().collect(
                                        function(valueTPElem, anIndex) {
                                            var valueElem;

                                            valueElem = TP.unwrap(valueTPElem);
                                            if (valueElem.checked) {
                                                return anIndex;
                                            }
                                        });

            //  Removes nulls and undefineds
            return checkboxIndices.compact();
        };

        //  ---

        //  allowsMultiples

        //  checkbox elements allow multiples
        test.assert.isTrue(tpElem.allowsMultiples());

        //  ---

        //  addSelection (and deselectAll)

        //  (property defaults to 'value')
        await tpElem.deselectAll();
        await tpElem.addSelection(TP.ac('bar', 'baz'));
        test.assert.isEqualTo(getSelectedIndices(tpElem), TP.ac(1, 2));

        //  'value' property
        await tpElem.deselectAll();
        await tpElem.addSelection(TP.ac('foo', 'bar'), 'value');
        test.assert.isEqualTo(getSelectedIndices(tpElem), TP.ac(0, 1));

        //  'label' property
        await tpElem.deselectAll();
        await tpElem.addSelection(TP.ac('Red', 'Yellow'), 'label');
        test.assert.isEqualTo(getSelectedIndices(tpElem), TP.ac(0, 2));

        //  'id' property
        await tpElem.deselectAll();
        await tpElem.addSelection(TP.ac('input_checkbox_1', 'input_checkbox_2'), 'id');
        test.assert.isEqualTo(getSelectedIndices(tpElem), TP.ac(0, 1));

        //  'index' property
        await tpElem.deselectAll();
        await tpElem.addSelection(TP.ac(1, 2), 'index');
        test.assert.isEqualTo(getSelectedIndices(tpElem), TP.ac(1, 2));

        //  ---

        //  removeSelection (and deselectAll)

        //  (property defaults to 'value')
        await tpElem.deselectAll();
        await tpElem.addSelection(TP.ac('foo', 'bar'));
        await tpElem.removeSelection('baz');
        test.assert.isEqualTo(getSelectedIndices(tpElem), TP.ac(0, 1));

        await tpElem.deselectAll();
        await tpElem.addSelection(TP.ac('bar', 'baz'));
        await tpElem.removeSelection('baz');
        test.assert.isEqualTo(getSelectedIndices(tpElem), TP.ac(1));

        //  'value' property
        await tpElem.deselectAll();
        await tpElem.addSelection(TP.ac('foo', 'baz'));
        await tpElem.removeSelection('bar', 'value');
        test.assert.isEqualTo(getSelectedIndices(tpElem), TP.ac(0, 2));

        await tpElem.deselectAll();
        await tpElem.addSelection(TP.ac('bar', 'baz'));
        await tpElem.removeSelection('bar', 'value');
        test.assert.isEqualTo(getSelectedIndices(tpElem), TP.ac(2));

        //  'label' property
        await tpElem.deselectAll();
        await tpElem.addSelection(TP.ac('Red', 'Yellow'), 'label');
        await tpElem.removeSelection('Blue', 'label');
        test.assert.isEqualTo(getSelectedIndices(tpElem), TP.ac(0, 2));

        await tpElem.deselectAll();
        await tpElem.addSelection(TP.ac('Red', 'Blue'), 'label');
        await tpElem.removeSelection('Blue', 'label');
        test.assert.isEqualTo(getSelectedIndices(tpElem), TP.ac(0));

        //  'id' property
        await tpElem.deselectAll();
        await tpElem.addSelection(TP.ac('input_checkbox_1', 'input_checkbox_2'), 'id');
        await tpElem.removeSelection('input_checkbox_3', 'id');
        test.assert.isEqualTo(getSelectedIndices(tpElem), TP.ac(0, 1));

        await tpElem.deselectAll();
        await tpElem.addSelection(TP.ac('input_checkbox_1', 'input_checkbox_3'), 'id');
        await tpElem.removeSelection('input_checkbox_3', 'id');
        test.assert.isEqualTo(getSelectedIndices(tpElem), TP.ac(0));

        //  'index' property
        await tpElem.deselectAll();
        await tpElem.addSelection(TP.ac(1, 2), 'index');
        await tpElem.removeSelection(0, 'index');
        test.assert.isEqualTo(getSelectedIndices(tpElem), TP.ac(1, 2));

        await tpElem.deselectAll();
        await tpElem.addSelection(TP.ac(0, 1), 'index');
        await tpElem.removeSelection(0, 'index');
        test.assert.isEqualTo(getSelectedIndices(tpElem), TP.ac(1));

        //  ---

        //  selectAll

        await tpElem.selectAll();
        test.assert.isEqualTo(getSelectedIndices(tpElem), TP.ac(0, 1, 2));

        //  ---

        //  select (and deselectAll)

        //  (property defaults to 'value')
        await tpElem.deselectAll();
        await tpElem.select('bar');
        test.assert.isEqualTo(getSelectedIndices(tpElem), TP.ac(1));
        await tpElem.select('baz');
        test.assert.isEqualTo(getSelectedIndices(tpElem), TP.ac(1, 2));

        await tpElem.deselectAll();
        await tpElem.select(TP.ac('foo', 'baz'));
        test.assert.isEqualTo(getSelectedIndices(tpElem), TP.ac(0, 2));

        //  ---

        //  select (with RegExp)

        await tpElem.deselectAll();
        await tpElem.select(/ba/);
        test.assert.isEqualTo(getSelectedIndices(tpElem), TP.ac(1, 2));

        //  ---

        //  deselect (and selectAll)

        //  (property defaults to 'value')
        await tpElem.selectAll();
        await tpElem.deselect('bar');
        test.assert.isEqualTo(getSelectedIndices(tpElem), TP.ac(0, 2));
        await tpElem.deselect('baz');
        test.assert.isEqualTo(getSelectedIndices(tpElem), TP.ac(0));

        await tpElem.selectAll();
        await tpElem.deselect(TP.ac('foo', 'baz'));
        test.assert.isEqualTo(getSelectedIndices(tpElem), TP.ac(1));

        //  ---

        //  deselect (with RegExp)

        await tpElem.selectAll();
        await tpElem.deselect(/ba/);
        test.assert.isEqualTo(getSelectedIndices(tpElem), TP.ac(0));
    });
});

//  ------------------------------------------------------------------------

TP.html.XMLNS.Type.describe('html: data binding of standard elements',
function() {

    var loadURI,
        unloadURI,

        windowContext;

    loadURI = TP.uc('~lib_test/src/html/HTMLContent.xhtml');

    unloadURI = TP.uc(TP.sys.cfg('path.blank_page'));

    //  ---

    this.before(
        async function(suite, options) {

            windowContext = this.getDriver().get('windowContext');

            await this.getDriver().setLocation(loadURI);

            this.startTrackingSignals();
        });

    //  ---

    this.after(
        async function(suite, options) {

            this.stopTrackingSignals();

            //  Unload the current page by setting it to the blank
            await this.getDriver().setLocation(unloadURI);

            //  Unregister the URI to avoid a memory leak
            loadURI.unregister();
        });

    //  ---

    this.it('data binding to scalar values', async function(test, options) {

        var modelObj,
            tpElem;

        modelObj = TP.lang.Object.construct();
        modelObj.defineAttribute('salary');

        tpElem = TP.byId('span', windowContext);

        await tpElem.defineBinding('value', modelObj, 'salary');

        //  Set the value of 'salary' on the model object. The binding should
        //  cause the value of 'salary' on the observer to update
        modelObj.set('salary', 42000);

        await TP.signal.resolveDeferreds();

        test.assert.isEqualTo(
                    modelObj.get('salary'),
                    tpElem.get('value').asNumber());

        //  Destroy the binding
        tpElem.destroyBinding('value', modelObj, 'salary');

        modelObj.set('salary', 45000);

        //  Because there is now no binding between these two, tpElem should
        //  still have the value of 42000 set above.
        test.refute.isEqualTo(
                    modelObj.get('salary'),
                    tpElem.get('value').asNumber());
    });

    //  ---

    this.it('data binding to complex object values', function(test, options) {
        //  empty
    }).todo();

    //  ---

    this.it('data binding "value" to path scalar values', async function(test, options) {

        var modelObj,

            tpElem,
            path;

        modelObj = TP.json2js('{"record":{"salary":"10"}}');

        tpElem = TP.byId('span', windowContext);
        path = TP.apc('record.salary');

        await tpElem.defineBinding('value', modelObj, path);

        modelObj.set(path, 42000);

        await TP.signal.resolveDeferreds();

        test.assert.isEqualTo(
                    modelObj.get(path),
                    tpElem.get('value').asNumber());

        //  Destroy the binding
        tpElem.destroyBinding('value', modelObj, path);

        modelObj.set(path, 45000);

        //  Because there is now no binding between these two, tpElem should
        //  still have the value of 42000 set above.
        test.refute.isEqualTo(
                    modelObj.get(path),
                    tpElem.get('value').asNumber());
    });

    //  ---

    this.it('data binding "value" to path complex values', function(test, options) {
        //  empty
    }).todo();
});

//  ------------------------------------------------------------------------
//  end
//  ========================================================================
