summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/browsers/browsing-the-web/navigating-across-documents/empty-iframe-load-event.html
blob: b9108f99377017af3e853837613bd66b1f1a5dde (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
<!doctype html>
<title>load event for empty iframe in relation to the event loop</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script>
setup({explicit_done:true});
let ran = false;

onload = function() {
    let iframe = document.createElement("iframe");
    iframe.onload = function() {
        test(function() {
            assert_equals(ran, false, 'Expected onload to run first');
        }, "Check execution order on load handler");
        if (ran) {
            done();
        } else {
            ran = true;
        }
    };
    document.body.appendChild(iframe);

    // Nested timeout to accommodate Gecko, because the it seems
    // the outer setTimeout takes its slot in the event queue right away
    // but the load event task takes its slot only at the end of this script.
    setTimeout(function() {
        setTimeout(function() {
            test(function() {
                assert_equals(ran, true, 'Expected nested setTimeout to run second');
            }, "Check execution order from nested timeout");
            if (ran) {
                done();
            } else {
                ran = true;
            }
        });
    });
};
</script>