aboutsummaryrefslogtreecommitdiffstats
path: root/tools/node_modules/expresso/deps/jscoverage/doc/example-jsunit/jsunit/app/testContainerController.html
blob: 3130d76a6ca08edc65f546f9cf64e0e07cbaacd5 (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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>JsUnit Test Container Controller</title>
    <script language="javascript" type="text/javascript">
        var containerReady = false;

        function init() {
            containerReady = true;
        }

        function isPageLoaded() {
            if (!containerReady)
                return false;

            var isTestPageLoaded = false;

            try {
                // attempt to access the var isTestPageLoaded in the testFrame
                if (typeof(top.testManager.containerTestFrame.isTestPageLoaded) != 'undefined') {
                    isTestPageLoaded = top.testManager.containerTestFrame.isTestPageLoaded;
                }

                // ok, if the above did not throw an exception, then the
                // variable is defined. If the onload has not fired in the
                // testFrame then isTestPageLoaded is still false. Otherwise
                // the testFrame has set it to true
            }
            catch (e) {
                // an error occured while attempting to access the isTestPageLoaded
                // in the testFrame, therefore the testFrame has not loaded yet
                isTestPageLoaded = false;
            }
            return isTestPageLoaded;
        }

        function isContainerReady() {
            return containerReady;
        }

        function setNotReady() {
            try {
                // attempt to set the isTestPageLoaded variable
                // in the test frame to false.
                top.testManager.containerTestFrame.isTestPageLoaded = false;
            }
            catch (e) {
                // testFrame.isTestPageLoaded not available... ignore
            }
        }
        function setTestPage(testPageURI) {
            setNotReady();
            top.jsUnitParseParms(testPageURI);
            testPageURI = appendCacheBusterParameterTo(testPageURI);
            try {
                top.testManager.containerTestFrame.location.href = testPageURI;
            } catch (e) {
            }
        }

        function appendCacheBusterParameterTo(testPageURI) {
            if (testPageURI.indexOf("?") == -1)
                testPageURI += "?";
            else
                testPageURI += "&";
            testPageURI += "cacheBuster=";
            testPageURI += new Date().getTime();
            return testPageURI;
        }
    </script>
</head>

<body onload="init()">
Test Container Controller
</body>
</html>