Bug 1534399 - Don't allow disabling non-author sheets. r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D23624

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Cameron McCormack 2019-03-15 12:54:17 +00:00
Родитель 2d9c404352
Коммит 716d720e13
3 изменённых файлов: 26 добавлений и 0 удалений

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

@ -29,3 +29,4 @@ skip-if = ((os == 'win' && bits!=64) || (os=='linux' && bits==32) || os == 'mac'
support-files =
test_fontVariationsAPI.css
[test_fontFaceGeneric.xul]
[test_ua_sheet_disable.html]

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

@ -0,0 +1,20 @@
<!DOCTYPE html>
<title>Test for bug 1534399</title>
<script type="application/javascript" src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
<script>
function start() {
let sheet = InspectorUtils.getAllStyleSheets(document, false)[0];
ok(sheet.href.indexOf("test.css") == -1, "Shouldn't have found the author sheet");
is(sheet.disabled, false, "Sheet should initially be enabled");
sheet.disabled = true;
is(sheet.disabled, false, "Shouldn't be able to disable a UA sheet");
SimpleTest.finish();
}
SimpleTest.waitForExplicitFinish();
document.addEventListener('DOMContentLoaded', start)
</script>

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

@ -241,6 +241,11 @@ void StyleSheet::ApplicableStateChanged(bool aApplicable) {
}
void StyleSheet::SetDisabled(bool aDisabled) {
// Only allow disabling author sheets.
if (mParsingMode != css::eAuthorSheetFeatures) {
return;
}
if (aDisabled == Disabled()) {
return;
}