summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/semantics/interactive-elements/the-dialog-element/dialog-return-value.html
blob: 2a80de65a15a1b291890746306fea4238c7aeea8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<!DOCTYPE html>
<html>
<head>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<dialog></dialog>
<script>
test(function() {
    dialog = document.querySelector('dialog');
    assert_equals(dialog.returnValue, '');

    dialog.returnValue = 'Setting value directly';
    assert_equals(dialog.returnValue, 'Setting value directly');

    dialog.returnValue = null;
    assert_equals(dialog.returnValue, 'null');

    dialog.returnValue = '';
    assert_equals(dialog.returnValue, '');

    dialog.returnValue = 7;
    assert_equals(dialog.returnValue, '7');

    dialog.show();
    dialog.close('Return value set from close()');
    assert_equals(dialog.returnValue, 'Return value set from close()');

    dialog.show();
    dialog.close('');
    assert_equals(dialog.returnValue, '');

    dialog.show();
    dialog.close(null);
    assert_equals(dialog.returnValue, 'null');

    dialog.returnValue = 'Should not change because no argument to close()';
    dialog.show();
    dialog.close();
    assert_equals(dialog.returnValue, 'Should not change because no argument to close()');

    dialog.returnValue = 'Should not change because of undefined argument to close()';
    dialog.show();
    dialog.close(undefined);
    assert_equals(dialog.returnValue, 'Should not change because of undefined argument to close()');

    dialog.returnValue = 'Should not change because of no-op close()';
    dialog.close('blah');
    assert_equals(dialog.returnValue, 'Should not change because of no-op close()');
}, "Tests dialog.returnValue is settable and returns the last value set.");
</script>
</body>
</html>