Bug 1844493 - Remove dom.moduleScripts.enabled pref r=smaug,jonco

Differential Revision: https://phabricator.services.mozilla.com/D184072
This commit is contained in:
Gregory Pappas 2023-07-20 10:03:46 +00:00
parent e0bf5df1bc
commit 1b2e2757ff
11 changed files with 139 additions and 217 deletions

View File

@ -18125,11 +18125,6 @@ void Document::RecordNavigationTiming(ReadyState aReadyState) {
}
}
bool Document::ModuleScriptsEnabled() const {
return nsContentUtils::IsChromeDoc(this) ||
StaticPrefs::dom_moduleScripts_enabled();
}
bool Document::ImportMapsEnabled() const {
return nsContentUtils::IsChromeDoc(this) ||
StaticPrefs::dom_importMaps_enabled();

View File

@ -4029,8 +4029,6 @@ class Document : public nsINode,
mozilla::dom::FeaturePolicy* FeaturePolicy() const;
bool ModuleScriptsEnabled() const;
bool ImportMapsEnabled() const;
/**

View File

@ -1,32 +0,0 @@
<html>
<body>
<script>
// Helper methods.
function ok(a, msg) {
parent.postMessage({ check: !!a, msg }, "*")
}
function is(a, b, msg) {
ok(a === b, msg);
}
function finish() {
parent.postMessage({ done: true }, "*");
}
</script>
<script id="a" nomodule>42</script>
<script>
// Let's test the behavior of nomodule attribute and noModule getter/setter.
var a = document.getElementById("a");
ok(!("noModule" in a), "When modules are disabled HTMLScriptElement.noModule is not defined");
</script>
<script>var foo = 42;</script>
<script nomodule>foo = 43;</script>
<script>
is(foo, 43, "nomodule attribute is ignored when modules are disabled");
finish();
</script>
</body>
</html>

View File

@ -188,22 +188,73 @@ support-files =
!/gfx/layers/apz/test/mochitest/apz_test_utils.js
[test_a_text.html]
[test_allowMedia.html]
skip-if = (verify && (os == 'linux' || os == 'win')) || ((!debug && os == "mac" && bits == 64) || (debug && os == "win") || (debug && os == "linux" && os_version == '18.04')) #Bug 1434744
[test_anchor_href_cache_invalidation.html]
[test_base_attributes_reflection.html]
[test_bug1003539.html]
[test_bug100533.html]
[test_bug1013316.html]
[test_bug1045270.html]
[test_bug1089326.html]
[test_bug109445.html]
[test_bug109445.xhtml]
[test_bug1146116.html]
[test_bug1166138.html]
[test_bug1203668.html]
[test_bug1230665.html]
[test_bug1250401.html]
[test_bug1260664.html]
[test_bug1260704.html]
skip-if =
http3
http2
[test_bug1261673.html]
skip-if = (os == 'android' || os == 'mac')
[test_bug1261674-1.html]
skip-if = (os == 'android' || os == 'mac')
[test_bug1261674-2.html]
skip-if = (os == 'mac')
[test_bug1264157.html]
[test_bug1279218.html]
[test_bug1287321.html]
[test_bug1292522_same_domain_with_different_port_number.html]
skip-if =
http3
http2
[test_bug1295719_event_sequence_for_arrow_keys.html]
skip-if = os == "android" # up/down arrow keys not supported on android
[test_bug1295719_event_sequence_for_number_keys.html]
[test_bug1297.html]
[test_bug1310865.html]
[test_bug1315146.html]
skip-if =
http3
http2
[test_bug1322678.html]
skip-if = toolkit == "android"
[test_bug1323815.html]
[test_bug1366.html]
[test_bug1400.html]
[test_bug143220.html]
[test_bug1472426.html]
[test_bug1682.html]
[test_bug1785739.html]
[test_bug182279.html]
[test_bug1823.html]
[test_bug196523.html]
skip-if =
http3
http2
[test_bug199692.html]
[test_bug2082.html]
[test_bug209275.xhtml]
skip-if = toolkit == 'android' #TIMED_OUT
[test_bug237071.html]
[test_bug242709.html]
[test_bug24958.html]
[test_bug255820.html]
[test_bug259332.html]
[test_bug274626.html]
[test_bug277724.html]
[test_bug277890.html]
@ -213,8 +264,12 @@ skip-if = toolkit == 'android' #TIMED_OUT
[test_bug300691-1.html]
[test_bug300691-2.html]
[test_bug300691-3.xhtml]
[test_bug311681.html]
[test_bug311681.xhtml]
[test_bug324378.html]
[test_bug330705-1.html]
[test_bug332246.html]
[test_bug332848.xhtml]
[test_bug332893-1.html]
[test_bug332893-2.html]
[test_bug332893-3.html]
@ -223,6 +278,7 @@ skip-if = toolkit == 'android' #TIMED_OUT
[test_bug332893-6.html]
[test_bug332893-7.html]
[test_bug3348.html]
[test_bug340017.xhtml]
[test_bug340800.html]
[test_bug347174.html]
[test_bug347174_write.html]
@ -230,12 +286,17 @@ skip-if = toolkit == 'android' #TIMED_OUT
[test_bug347174_xslp.html]
[test_bug353415-1.html]
[test_bug353415-2.html]
[test_bug359657.html]
[test_bug369370.html]
skip-if = toolkit == "android"
os == 'linux' # disabled on linux bug 1258103
[test_bug371375.html]
[test_bug372098.html]
[test_bug373589.html]
[test_bug375003-1.html]
[test_bug375003-2.html]
[test_bug377624.html]
[test_bug380383.html]
[test_bug383383.html]
[test_bug383383_2.xhtml]
[test_bug384419.html]
@ -251,6 +312,9 @@ skip-if = toolkit == 'android' #TIMED_OUT
[test_bug394700.html]
[test_bug395107.html]
[test_bug401160.xhtml]
[test_bug402680.html]
[test_bug403868.html]
[test_bug403868.xhtml]
[test_bug405242.html]
[test_bug406596.html]
[test_bug417760.html]
@ -259,9 +323,15 @@ skip-if = toolkit == 'android' #TIMED_OUT
[test_bug428135.xhtml]
[test_bug430351.html]
skip-if = toolkit == 'android' # Bug 1525959
[test_bug435128.html]
skip-if = true # Disabled for timeouts.
[test_bug441930.html]
[test_bug442801.html]
[test_bug445004.html]
skip-if = true # Disabled permanently (bug 559932).
[test_bug446483.html]
[test_bug448166.html]
[test_bug448564.html]
[test_bug456229.html]
[test_bug458037.xhtml]
allow_xul_xbl = true
@ -269,9 +339,19 @@ skip-if =
http3
http2
[test_bug460568.html]
[test_bug463104.html]
[test_bug478251.html]
[test_bug481335.xhtml]
skip-if = toolkit == 'android' #TIMED_OUT
[test_bug481440.html]
[test_bug481647.html]
[test_bug482659.html]
[test_bug486741.html]
[test_bug489532.html]
[test_bug497242.xhtml]
[test_bug499092.html]
[test_bug500885.html]
[test_bug512367.html]
[test_bug514856.html]
[test_bug518122.html]
[test_bug519987.html]
@ -307,6 +387,7 @@ skip-if = toolkit == 'android' #TIMED_OUT
[test_bug567938-4.html]
[test_bug569955.html]
[test_bug573969.html]
[test_bug57600.html]
[test_bug579079.html]
[test_bug582412-1.html]
[test_bug582412-2.html]
@ -344,8 +425,8 @@ skip-if =
[test_bug611189.html]
[test_bug612730.html]
skip-if = toolkit == 'android' # form control not selected/checked with synthesizeMouse
[test_bug613113.html]
[test_bug613019.html]
[test_bug613113.html]
[test_bug613722.html]
[test_bug613979.html]
[test_bug615595.html]
@ -392,6 +473,8 @@ skip-if =
[test_bug669012.html]
[test_bug674558.html]
[test_bug674927.html]
[test_bug677495-1.html]
[test_bug677495.html]
[test_bug677658.html]
[test_bug682886.html]
[test_bug691.html]
@ -400,10 +483,13 @@ skip-if =
skip-if = toolkit == 'android' # Bug 1525959
[test_bug696.html]
[test_bug717819.html]
[test_bug741266.html]
skip-if = toolkit == "android" # Android: needs control of popup window size
[test_bug742030.html]
[test_bug742549.html]
[test_bug745685.html]
[test_bug763626.html]
[test_bug765780.html]
[test_bug780993.html]
[test_bug787134.html]
[test_bug797113.html]
@ -417,6 +503,11 @@ skip-if = toolkit == 'android' # Bug 1525959
[test_bug845057.html]
[test_bug869040.html]
[test_bug870787.html]
[test_bug871161.html]
support-files = file_bug871161-1.html file_bug871161-2.html
skip-if =
http3
http2
[test_bug874758.html]
[test_bug879319.html]
[test_bug885024.html]
@ -424,13 +515,6 @@ skip-if = toolkit == 'android' # Bug 1525959
[test_bug95530.html]
[test_bug969346.html]
[test_bug982039.html]
[test_bug1003539.html]
[test_bug1045270.html]
[test_bug1089326.html]
[test_bug1146116.html]
[test_bug1264157.html]
[test_bug1287321.html]
[test_bug1323815.html]
[test_change_crossorigin.html]
skip-if =
http3
@ -438,15 +522,23 @@ skip-if =
[test_checked.html]
[test_dir_attributes_reflection.html]
[test_dl_attributes_reflection.html]
[test_document-element-inserted.html]
[test_documentAll.html]
[test_element_prototype.html]
[test_embed_attributes_reflection.html]
[test_fakepath.html]
[test_filepicker_default_directory.html]
[test_focusshift_button.html]
[test_form-parsing.html]
[test_formData.html]
[test_formSubmission.html]
skip-if = toolkit == 'android' #TIMED_OUT
[test_formSubmission2.html]
skip-if = toolkit == 'android'
[test_formelements.html]
[test_fragment_form_pointer.html]
[test_frame_count_with_synthetic_doc.html]
[test_getElementsByName_after_mutation.html]
[test_hidden.html]
[test_html_attributes_reflection.html]
[test_htmlcollection.html]
@ -469,8 +561,15 @@ tags = openwindow
[test_iframe_sandbox_refresh.html]
[test_iframe_sandbox_same_origin.html]
[test_iframe_sandbox_workers.html]
[test_img_attributes_reflection.html]
[test_imageSrcSet.html]
[test_image_clone_load.html]
skip-if =
http3
http2
[test_img_attributes_reflection.html]
[test_input_file_cancel_event.html]
[test_input_files_not_nsIFile.html]
[test_input_lastInteractiveValue.html]
[test_inputmode.html]
[test_li_attributes_reflection.html]
[test_link_attributes_reflection.html]
@ -478,8 +577,16 @@ tags = openwindow
[test_map_attributes_reflection.html]
[test_meta_attributes_reflection.html]
[test_mod_attributes_reflection.html]
[test_multipleFilePicker.html]
[test_named_options.html]
[test_nested_invalid_fieldsets.html]
[test_nestediframe.html]
[test_non-ascii-cookie.html]
support-files = file_cookiemanager.js
skip-if =
xorigin
http3
http2
[test_object_attributes_reflection.html]
[test_ol_attributes_reflection.html]
[test_option_defaultSelected.html]
@ -488,129 +595,21 @@ tags = openwindow
[test_q_attributes_reflection.html]
[test_restore_from_parser_fragment.html]
[test_rowscollection.html]
[test_script_module.html]
support-files =
file_script_module.html
[test_set_input_files.html]
[test_srcdoc-2.html]
[test_srcdoc.html]
[test_style_attributes_reflection.html]
[test_track.html]
[test_ul_attributes_reflection.html]
[test_input_file_cancel_event.html]
[test_input_files_not_nsIFile.html]
[test_input_lastInteractiveValue.html]
[test_fragment_form_pointer.html]
[test_bug1682.html]
[test_bug1823.html]
[test_bug57600.html]
[test_bug196523.html]
skip-if =
http3
http2
[test_bug199692.html]
[test_bug255820.html]
[test_bug259332.html]
[test_bug311681.html]
[test_bug311681.xhtml]
[test_bug324378.html]
[test_bug332848.xhtml]
[test_bug340017.xhtml]
[test_bug359657.html]
[test_bug369370.html]
skip-if = toolkit == "android"
os == 'linux' # disabled on linux bug 1258103
[test_bug380383.html]
[test_bug402680.html]
[test_bug403868.html]
[test_bug403868.xhtml]
[test_bug435128.html]
skip-if = true # Disabled for timeouts.
[test_bug463104.html]
[test_form-parsing.html]
[test_documentAll.html]
[test_document-element-inserted.html]
[test_bug445004.html]
skip-if = true # Disabled permanently (bug 559932).
[test_bug446483.html]
[test_bug448564.html]
[test_bug478251.html]
[test_bug481440.html]
[test_bug481647.html]
[test_bug482659.html]
[test_bug486741.html]
[test_bug489532.html]
[test_bug497242.xhtml]
[test_bug499092.html]
[test_bug512367.html]
[test_bug677495.html]
[test_bug677495-1.html]
[test_bug741266.html]
skip-if = toolkit == "android" # Android: needs control of popup window size
[test_non-ascii-cookie.html]
support-files = file_cookiemanager.js
skip-if =
xorigin
http3
http2
[test_bug765780.html]
[test_bug871161.html]
support-files = file_bug871161-1.html file_bug871161-2.html
skip-if =
http3
http2
[test_bug1013316.html]
[test_viewport_resize.html]
[test_window_open_close.html]
tags = openwindow
skip-if = (toolkit == "android" && debug) || (os == "linux") || (os == "win" && debug && bits == 64) # Bug 1533759
[test_viewport_resize.html]
[test_image_clone_load.html]
skip-if =
http3
http2
[test_bug1203668.html]
[test_bug1166138.html]
[test_bug1230665.html]
[test_filepicker_default_directory.html]
[test_bug1250401.html]
[test_bug1260664.html]
[test_bug1261673.html]
skip-if = (os == 'android' || os == 'mac')
[test_bug1261674-1.html]
skip-if = (os == 'android' || os == 'mac')
[test_bug1261674-2.html]
skip-if = (os == 'mac')
[test_bug1260704.html]
skip-if =
http3
http2
[test_allowMedia.html]
skip-if = (verify && (os == 'linux' || os == 'win')) || ((!debug && os == "mac" && bits == 64) || (debug && os == "win") || (debug && os == "linux" && os_version == '18.04')) #Bug 1434744
[test_bug1292522_same_domain_with_different_port_number.html]
skip-if =
http3
http2
[test_bug1295719_event_sequence_for_arrow_keys.html]
skip-if = os == "android" # up/down arrow keys not supported on android
[test_bug1295719_event_sequence_for_number_keys.html]
[test_bug1310865.html]
[test_bug1315146.html]
skip-if =
http3
http2
[test_bug1322678.html]
skip-if = toolkit == "android"
[test_bug1472426.html]
[test_bug1785739.html]
[test_fakepath.html]
[test_script_module.html]
support-files =
file_script_module.html
file_script_nomodule.html
[test_getElementsByName_after_mutation.html]
[test_bug1279218.html]
[test_set_input_files.html]
[test_nestediframe.html]
[test_multipleFilePicker.html]
[test_window_open_from_closing.html]
skip-if = toolkit == "android" # test does not function on android due to aggressive background tab freezing
support-files =
file_window_close_and_open.html
file_broadcast_load.html
[test_frame_count_with_synthetic_doc.html]
file_broadcast_load.html

View File

@ -10,7 +10,7 @@
<script>
onmessage = (e) => {
if ("done" in e.data) {
next();
SimpleTest.finish();
} else if ("check" in e.data) {
ok(e.data.check, e.data.msg);
} else {
@ -18,38 +18,13 @@ onmessage = (e) => {
}
}
var tests = [
function() {
SpecialPowers.pushPrefEnv({"set":[["dom.moduleScripts.enabled", true]]})
.then(() => {
var ifr = document.createElement('iframe');
ifr.src = "file_script_module.html";
document.body.appendChild(ifr);
});
},
function() {
SpecialPowers.pushPrefEnv({"set":[["dom.moduleScripts.enabled", false]]})
.then(() => {
var ifr = document.createElement('iframe');
ifr.src = "file_script_nomodule.html";
document.body.appendChild(ifr);
});
},
];
var ifr = document.createElement('iframe');
ifr.src = "file_script_module.html";
document.body.appendChild(ifr);
SimpleTest.waitForExplicitFinish();
next();
function next() {
if (!tests.length) {
SimpleTest.finish();
return;
}
var test = tests.shift();
test();
}
</script>
</body>

View File

@ -917,8 +917,7 @@ bool ScriptLoader::ProcessScriptElement(nsIScriptElement* aElement,
// the nomodule attribute will be ignored".
// "The nomodule attribute must not be specified on module scripts (and will
// be ignored if it is)."
if (mDocument->ModuleScriptsEnabled() && scriptKind == ScriptKind::eClassic &&
scriptContent->IsHTMLElement() &&
if (scriptKind == ScriptKind::eClassic && scriptContent->IsHTMLElement() &&
scriptContent->AsElement()->HasAttr(nsGkAtoms::nomodule)) {
return false;
}
@ -3561,19 +3560,17 @@ void ScriptLoader::PreloadURI(nsIURI* aURI, const nsAString& aCharset,
ScriptKind scriptKind = ScriptKind::eClassic;
if (mDocument->ModuleScriptsEnabled()) {
// Don't load nomodule scripts.
if (aNoModule) {
return;
}
// Don't load nomodule scripts.
if (aNoModule) {
return;
}
static const char kASCIIWhitespace[] = "\t\n\f\r ";
static const char kASCIIWhitespace[] = "\t\n\f\r ";
nsAutoString type(aType);
type.Trim(kASCIIWhitespace);
if (type.LowerCaseEqualsASCII("module")) {
scriptKind = ScriptKind::eModule;
}
nsAutoString type(aType);
type.Trim(kASCIIWhitespace);
if (type.LowerCaseEqualsASCII("module")) {
scriptKind = ScriptKind::eModule;
}
if (scriptKind == ScriptKind::eClassic && !aType.IsEmpty() &&

View File

@ -65,8 +65,7 @@ void nsIScriptElement::DetermineKindFromType(
GetScriptType(type);
if (!type.IsEmpty()) {
if (aOwnerDoc->ModuleScriptsEnabled() &&
type.LowerCaseEqualsASCII("module")) {
if (type.LowerCaseEqualsASCII("module")) {
mKind = ScriptKind::eModule;
}

View File

@ -50,7 +50,6 @@ worker.onmessage = function() {
worker.postMessage("dummy");
// --- test script modules
SpecialPowers.pushPrefEnv({set: [["dom.moduleScripts.enabled", true]]}, function() {
let testModuleScriptRedirectToData = document.getElementById("testModuleScriptRedirectToData");
testModuleScriptRedirectToData.onerror = function() {
ok(true, "module script that redirects to data: URI should not load");
@ -61,7 +60,6 @@ SpecialPowers.pushPrefEnv({set: [["dom.moduleScripts.enabled", true]]}, function
checkFinish();
}
testModuleScriptRedirectToData.src = "file_block_subresource_redir_to_data.sjs?modulescript";
});
</script>
</body>

View File

@ -16,7 +16,7 @@ interface HTMLScriptElement : HTMLElement {
attribute DOMString src;
[CEReactions, SetterThrows]
attribute DOMString type;
[CEReactions, SetterThrows, Pref="dom.moduleScripts.enabled"]
[CEReactions, SetterThrows]
attribute boolean noModule;
[CEReactions, SetterThrows]
attribute DOMString charset;

View File

@ -3147,12 +3147,6 @@
value: true
mirror: always
# Is support for module scripts (<script type="module">) enabled for content?
- name: dom.moduleScripts.enabled
type: bool
value: true
mirror: always
# Is support for import maps (<script type="importmap">) enabled for content?
- name: dom.importMaps.enabled
type: bool

View File

@ -1 +0,0 @@
prefs: [dom.moduleScripts.enabled:true]