Bug 801635 - Disable <input type='file'> for B2G. r+a=sicking

This commit is contained in:
Mounir Lamouri 2013-01-21 10:51:42 +00:00
Родитель 57215dab17
Коммит 7286245e03
4 изменённых файлов: 50 добавлений и 0 удалений

Просмотреть файл

@ -640,3 +640,7 @@ pref("webgl.can-lose-context-in-foreground", false);
// this fifo to trigger about:memory dumps, among other things.
pref("memory_info_dumper.watch_fifo.enabled", true);
pref("memory_info_dumper.watch_fifo.directory", "/data/local");
// <input type='file'> implementation is not complete. We have to disable the
// type to web content to help them do feature detection.
pref("dom.disable_input_file", true);

Просмотреть файл

@ -2714,6 +2714,11 @@ nsHTMLInputElement::ParseAttribute(int32_t aNamespaceID,
newType = kInputDefaultType->value;
aResult.SetTo(newType, &aValue);
}
if (newType == NS_FORM_INPUT_FILE &&
Preferences::GetBool("dom.disable_input_file", false)) {
newType = kInputDefaultType->value;
aResult.SetTo(newType, &aValue);
}
} else {
newType = kInputDefaultType->value;
}

Просмотреть файл

@ -49,6 +49,7 @@ MOCHITEST_FILES = \
test_valueasnumber_attribute.html \
test_experimental_forms_pref.html \
test_input_number_value.html \
test_input_file_b2g_disabled.html \
$(NULL)
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -0,0 +1,40 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=801635
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 801635</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript">
/** Test for Bug 801635 **/
var oldPrefValue = SpecialPowers.getBoolPref('dom.disable_input_file');
var input = document.createElement('input');
SpecialPowers.setBoolPref('dom.disable_input_file', true);
input.type='file';
is(input.type, 'text', "<input type='file'> should be disabled");
input.type ='text';
SpecialPowers.setBoolPref('dom.disable_input_file', false);
input.type='file';
is(input.type, 'file', "<input type='file'> should not be disabled");
SpecialPowers.setBoolPref('dom.disable_input_file', oldPrefValue);
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=801635">Disable &lt;input type='file'&gt; on B2G</a>
<p id="display"></p>
<div id="content" style="display: none">
</div>
<pre id="test">
</pre>
</body>
</html>