2009-05-07 12:37:33 -07:00
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
|
|
<!--
|
|
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=484176
|
|
|
|
-->
|
|
|
|
<head>
|
|
|
|
<title>Test SVG Switch</title>
|
|
|
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=484176">Mozilla Bug 484176</a>
|
|
|
|
<p id="display"></p>
|
|
|
|
<div id="content"></div>
|
|
|
|
|
|
|
|
<iframe id="svg" src="switch-helper.svg"></iframe>
|
|
|
|
|
|
|
|
<pre id="test">
|
|
|
|
<script class="testbody" type="text/javascript">
|
|
|
|
<![CDATA[
|
|
|
|
|
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
|
|
|
|
var test = 1;
|
|
|
|
|
|
|
|
function checkBounds(element, x, y, w, h)
|
|
|
|
{
|
|
|
|
var bbox = element.getBBox();
|
|
|
|
var name = element.nodeName;
|
|
|
|
|
|
|
|
is(bbox.x, x, test + " " + name + ".getBBox().x");
|
|
|
|
is(bbox.y, y, test + " " + name + ".getBBox().y");
|
|
|
|
is(bbox.width, w, test + " " + name + ".getBBox().width");
|
|
|
|
is(bbox.height, h, test + " " + name + ".getBBox().height");
|
|
|
|
++test;
|
|
|
|
}
|
|
|
|
|
2014-09-09 05:00:03 -07:00
|
|
|
function checkWidth(element, w)
|
2009-05-07 12:37:33 -07:00
|
|
|
{
|
|
|
|
var bbox = element.getBBox();
|
|
|
|
var name = element.nodeName;
|
|
|
|
|
|
|
|
is(bbox.width, w, test + " " + name + ".getBBox().width");
|
|
|
|
++test;
|
|
|
|
}
|
|
|
|
|
|
|
|
function run()
|
|
|
|
{
|
|
|
|
// Set accept_languages to something we know
|
2013-07-31 02:30:54 -07:00
|
|
|
SpecialPowers.pushPrefEnv({"set": [["intl.accept_languages", "en-gb,en,it"]]}, run1);
|
|
|
|
}
|
2009-05-07 12:37:33 -07:00
|
|
|
|
2013-07-31 02:30:54 -07:00
|
|
|
function run1()
|
|
|
|
{
|
2009-05-07 12:37:33 -07:00
|
|
|
try {
|
|
|
|
var doc = $("svg").contentDocument;
|
|
|
|
var s = doc.getElementById("s");
|
|
|
|
var first = doc.getElementById("first");
|
|
|
|
var second = doc.getElementById("second");
|
2014-09-09 05:00:03 -07:00
|
|
|
var third = doc.getElementById("third");
|
2009-05-07 12:37:33 -07:00
|
|
|
|
|
|
|
/* test for an exact match */
|
|
|
|
second.setAttribute("systemLanguage", "en-gb");
|
|
|
|
checkBounds(s, 75, 100, 50, 50);
|
|
|
|
|
|
|
|
/* test for a close match i.e. the same language prefix */
|
|
|
|
second.setAttribute("systemLanguage", "en-us");
|
2014-09-09 05:00:03 -07:00
|
|
|
checkWidth(s, 50);
|
2009-05-07 12:37:33 -07:00
|
|
|
|
|
|
|
/* test that we pick the first match */
|
|
|
|
first.setAttribute("systemLanguage", "it");
|
2014-09-09 05:00:03 -07:00
|
|
|
checkWidth(s, 70);
|
2009-05-07 12:37:33 -07:00
|
|
|
|
|
|
|
/* this time with reordering */
|
|
|
|
first.setAttribute("systemLanguage", "fr");
|
|
|
|
s.setAttribute("allowReorder", "yes");
|
|
|
|
|
|
|
|
/* test for an exact match */
|
|
|
|
second.setAttribute("systemLanguage", "en-gb");
|
2014-09-09 05:00:03 -07:00
|
|
|
checkWidth(s, 50);
|
2009-05-07 12:37:33 -07:00
|
|
|
|
|
|
|
/* test for a close match i.e. the same language prefix */
|
|
|
|
second.setAttribute("systemLanguage", "en-us");
|
2014-09-09 05:00:03 -07:00
|
|
|
checkWidth(s, 50);
|
2009-05-07 12:37:33 -07:00
|
|
|
|
|
|
|
/* test that we pick the best match */
|
|
|
|
second.setAttribute("systemLanguage", "it");
|
2014-09-09 05:00:03 -07:00
|
|
|
checkWidth(s, 50);
|
|
|
|
|
|
|
|
/* test that we use the default if nothing matches */
|
|
|
|
second.setAttribute("systemLanguage", "fr");
|
|
|
|
checkWidth(s, 80);
|
|
|
|
|
|
|
|
/* test we still ignore non-matches */
|
|
|
|
second.removeAttribute("systemLanguage");
|
|
|
|
third.setAttribute("systemLanguage", "fr");
|
|
|
|
checkWidth(s, 50);
|
|
|
|
|
|
|
|
/* check what happens if nothing matches */
|
|
|
|
second.setAttribute("systemLanguage", "fr");
|
|
|
|
checkWidth(s, 0);
|
2009-05-07 12:37:33 -07:00
|
|
|
|
|
|
|
/* test that we pick the best match */
|
|
|
|
first.setAttribute("systemLanguage", "en");
|
|
|
|
second.setAttribute("systemLanguage", "en-gb");
|
2014-09-09 05:00:03 -07:00
|
|
|
checkWidth(s, 50);
|
2009-05-07 12:37:33 -07:00
|
|
|
|
|
|
|
} finally {
|
|
|
|
SimpleTest.finish();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-02 09:59:38 -08:00
|
|
|
window.addEventListener("load", run, false);
|
2009-05-07 12:37:33 -07:00
|
|
|
|
|
|
|
]]>
|
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|