<!doctype html>
<title>TextTrack.mode</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<div id=log></div>
<script>
test(function(){
    var track = document.createElement('track');
    assert_equals(track.track.mode, 'disabled', 'initial');
    track.track.mode = 1;
    assert_equals(track.track.mode, 'disabled', '1');
    track.track.mode = '';
    assert_equals(track.track.mode, 'disabled', '""');
    track.track.mode = null;
    assert_equals(track.track.mode, 'disabled', 'null');
    track.track.mode = undefined;
    assert_equals(track.track.mode, 'disabled', 'undefined');
    track.track.mode = 'showing';
    assert_equals(track.track.mode, 'showing', 'showing (correct value)');
    track.track.mode = 'DISABLED';
    assert_equals(track.track.mode, 'showing', '"DISABLED"');
    track.track.mode = 'd\u0130sabled'; // dotted uppercase i
    assert_equals(track.track.mode, 'showing', '"d\u0130sabled" (dotted uppercase i)');
    track.track.mode = 'd\u0131sabled'; // dotless lowercase i
    assert_equals(track.track.mode, 'showing', '"d\u0131sabled" (dotless lowercase i)');
    track.track.mode = 'disabled ';
    assert_equals(track.track.mode, 'showing', '"disabled "');
    track.track.mode = ' disabled';
    assert_equals(track.track.mode, 'showing', '" disabled"');
    track.track.mode = {};
    assert_equals(track.track.mode, 'showing', '{}');
    track.track.mode = 'HIDDEN';
    assert_equals(track.track.mode, 'showing', '"HIDDEN"');
    track.track.mode = 'h\u0130dden'; // dotted uppercase i
    assert_equals(track.track.mode, 'showing', '"h\u0130dden" (dotted uppercase i)');
    track.track.mode = 'h\u0131dden'; // dotless lowercase i
    assert_equals(track.track.mode, 'showing', '"h\u0131dden" (dotless lowercase i)');
}, document.title+', wrong value');
test(function() {
    var track = document.createElement('track');
    assert_equals(track.track.mode, 'disabled', 'initial');
    track.track.mode = 'disabled'; // no-op
    assert_equals(track.track.mode, 'disabled', 'disabled (1)');
    track.track.mode = 'hidden';
    assert_equals(track.track.mode, 'hidden', 'hidden (1)');
    track.track.mode = 'hidden'; // no-op
    assert_equals(track.track.mode, 'hidden', 'hidden (2)');
    track.track.mode = 'showing';
    assert_equals(track.track.mode, 'showing', 'showing (1)');
    track.track.mode = 'showing'; // no-op
    assert_equals(track.track.mode, 'showing', 'showing (2)');
    track.track.mode = {toString:function() { return 'disabled'; }};
    assert_equals(track.track.mode, 'disabled', '{toString:...}');
}, document.title+', correct value');
</script>
