chromium/third_party/blink/web_tests/fast/harness/user-preferred-language.html

<html>
    <head>
        <script>
            
            if (window.testRunner)
                testRunner.dumpAsText();
            
            function test(message, success)
            {
                var li = document.createElement("li");
                var text = document.createTextNode(message + ': ' + (success ? 'PASS' : 'FAIL'));
                li.appendChild(text);
                document.getElementById("console").appendChild(li);
            }
        
            function runTest()
            {
                var languages = internals.userPreferredLanguages();

                test('internals.userPreferredLanguages returns a non-empty array', languages.length);

                languages.unshift("first-language");
                languages.push("last-language");
                internals.setUserPreferredLanguages(languages);

                var newLanguages = internals.userPreferredLanguages();
                var sameContents = newLanguages.length == languages.length;
                if (sameContents) {
                    for (var i = 0; i < newLanguages.length; i++) {
                        if (newLanguages[i] != languages[i]) {
                            sameContents = false;
                            break;
                        }
                    }
                }
                test('internals.userPreferredLanguages is mutable, and returns the same value passed to it', sameContents);
            }
        
        </script>
    </head>
    <body onload="runTest()">
        <p>This test verifies that internals.userPreferredLanguages returns a mutable Array of the user's preferred languages.</p>
        <ul id="console"></ul>
    </body>
</html>