From 67d336a6f27889bdef4723194b6611d049830266 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Fri, 17 Jan 2020 17:11:06 +0100 Subject: No issue - Fix unsafe http methods on HTTP/2 with TLSv1.3 0RTT. --- netwerk/protocol/http/Http2Stream.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/netwerk/protocol/http/Http2Stream.cpp b/netwerk/protocol/http/Http2Stream.cpp index 22d8142c9..4401a2612 100644 --- a/netwerk/protocol/http/Http2Stream.cpp +++ b/netwerk/protocol/http/Http2Stream.cpp @@ -1478,8 +1478,12 @@ bool Http2Stream::Do0RTT() { MOZ_ASSERT(mTransaction); - mAttempting0RTT = true; - return mTransaction->Do0RTT(); + if mTransaction->Do0RTT() { + mAttempting0RTT = true; + } else { + mAttempting0RTT = false; + } + return mAttempting0RTT; } nsresult -- cgit v1.2.3 From a2073c54b4d86b0049807b8c427209dc17388ece Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Sat, 18 Jan 2020 02:08:53 +0100 Subject: Revert "No issue - Fix unsafe http methods on HTTP/2 with TLSv1.3 0RTT." This reverts commit 67d336a6f27889bdef4723194b6611d049830266. --- netwerk/protocol/http/Http2Stream.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/netwerk/protocol/http/Http2Stream.cpp b/netwerk/protocol/http/Http2Stream.cpp index 4401a2612..22d8142c9 100644 --- a/netwerk/protocol/http/Http2Stream.cpp +++ b/netwerk/protocol/http/Http2Stream.cpp @@ -1478,12 +1478,8 @@ bool Http2Stream::Do0RTT() { MOZ_ASSERT(mTransaction); - if mTransaction->Do0RTT() { - mAttempting0RTT = true; - } else { - mAttempting0RTT = false; - } - return mAttempting0RTT; + mAttempting0RTT = true; + return mTransaction->Do0RTT(); } nsresult -- cgit v1.2.3 From 82dffb32bdf829032e2fd38e9eba93729a2cc357 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Sat, 18 Jan 2020 13:01:53 +0100 Subject: Add component documentation for the HTML5 parser. --- docs/Component docs/HTML Parser updates.md | 63 ++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 docs/Component docs/HTML Parser updates.md diff --git a/docs/Component docs/HTML Parser updates.md b/docs/Component docs/HTML Parser updates.md new file mode 100644 index 000000000..7a2c76e94 --- /dev/null +++ b/docs/Component docs/HTML Parser updates.md @@ -0,0 +1,63 @@ +# Updating HTML5 parser code + +Our html5 parser is based on the java html5 parser from [Validator.nu](http://about.validator.nu/htmlparser/) by Henri Sivonen. It has been adopted by Mozilla and further updated, and has been imported as a whole into the UXP tree to have an independent and maintainable source of it that doesn't rely on external sources. + +## Stages +Updating the parser code consists of 3 stages: +- Making updates to the html parser source in java +- Let the java parser regenerate part of its own code after the change +- Translate the java source to C++ + +This process was best explained in the [following Bugzilla comment](https://bugzilla.mozilla.org/show_bug.cgi?id=1378079#c6), which explain how to add a new attribute name to html5, inserted in this document for convenience: + +>> Is +>> there any documentation on how to add a new nsHtml5AttributeName? +> +> I don't recall. I should get around to writing it. +> +>> Looks like +>> I need to clone hg.mozilla.org/projects/htmlparser/ and generate a hash with +>> it? +> +> Yes. Here's how: +> +> `cd parser/html/java/` +> `make sync` +> +> Now you have a clone of [https://hg.mozilla.org/projects/htmlparser/](https://hg.mozilla.org/projects/htmlparser/) in > parser/html/java/htmlparser/ +> +> `cd htmlparser/src/` +> `$EDITOR nu/validator/htmlparser/impl/AttributeName.java` +> +> Search for the word "uncomment" and uncomment stuff according to the two comments that talk about uncommenting +> Duplicate the declaration a normal attribute (nothings special in SVG mode, etc.). Let's use "alt", since it's the first one. +> In the duplicate, replace ALT with IS and "alt" with "is". +> Search for "ALT,", duplicate that line and change the duplicate to say "IS," +> Save. +> +> `javac nu/validator/htmlparser/impl/AttributeName.java` +> `java nu.validator.htmlparser.impl.AttributeName` +> +> Copy and paste the output into nu/validator/htmlparser/impl/AttributeName.java replacing the text below the comment "START GENERATED CODE" and above the very last "}". +> Recomment the bits that you uncommented earlier. +> Save. +> +> `cd ../..` - Back to parser/html/java/ +> `make translate` + +## Organizing commits + +**The html5 parser code is fragile due to its generation and translation before being used as C++ in our tree. Do not touch or commit anything without a code peer nearby with knowledge of the parser and the commit process (at this moment that means Gaming4JC (@g4jc)), and communicate the changes thoroughly.** + +To organize this properly in our repo, commits should be split up when making these kinds of changes: +1. Commit your code edits to the html parser +2. Regenerate java into a translation-ready source +3. Commit +4. Translate and regenerate C++ code +5. Check a build to make sure the changes have the intended result +6. Commit + +This is needed because the source edit will sometimes be in parts that are self-generated and may otherwise be lost in generation noise, and because we want to keep a strict separation between commits resulting from developer work and those resulting from running scripts/automated processes. + + + -- cgit v1.2.3 From b87a4551b52e8f999d05641e3ab889ed11f3a001 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Sat, 18 Jan 2020 13:17:09 +0100 Subject: No issue - Fix unsafe http methods on HTTP/2 with TLSv1.3 0RTT. --- netwerk/protocol/http/Http2Stream.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/netwerk/protocol/http/Http2Stream.cpp b/netwerk/protocol/http/Http2Stream.cpp index 22d8142c9..a9d926a53 100644 --- a/netwerk/protocol/http/Http2Stream.cpp +++ b/netwerk/protocol/http/Http2Stream.cpp @@ -1478,8 +1478,12 @@ bool Http2Stream::Do0RTT() { MOZ_ASSERT(mTransaction); - mAttempting0RTT = true; - return mTransaction->Do0RTT(); + if (mTransaction->Do0RTT()) { + mAttempting0RTT = true; + } else { + mAttempting0RTT = false; + } + return mAttempting0RTT; } nsresult -- cgit v1.2.3 From 63219a15b155aee142f316156b6578f027204129 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Sat, 18 Jan 2020 13:25:35 +0100 Subject: Minor update to the html5 parser component doc --- docs/Component docs/HTML Parser updates.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/Component docs/HTML Parser updates.md b/docs/Component docs/HTML Parser updates.md index 7a2c76e94..22a06e620 100644 --- a/docs/Component docs/HTML Parser updates.md +++ b/docs/Component docs/HTML Parser updates.md @@ -4,11 +4,11 @@ Our html5 parser is based on the java html5 parser from [Validator.nu](http://ab ## Stages Updating the parser code consists of 3 stages: -- Making updates to the html parser source in java +- Make updates to the html parser source in java - Let the java parser regenerate part of its own code after the change - Translate the java source to C++ -This process was best explained in the [following Bugzilla comment](https://bugzilla.mozilla.org/show_bug.cgi?id=1378079#c6), which explain how to add a new attribute name to html5, inserted in this document for convenience: +This process was best explained in the [following Bugzilla comment](https://bugzilla.mozilla.org/show_bug.cgi?id=1378079#c6), which explain how to add a new attribute name ("is") to html5, inserted in this document for convenience: >> Is >> there any documentation on how to add a new nsHtml5AttributeName? -- cgit v1.2.3 From c137a4045cbfcbd5a39f018b553089e0fd571d2c Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Sat, 18 Jan 2020 13:17:41 -0500 Subject: Issue #1359 - Pointlessly rename greprefs.. again. --- modules/libpref/Preferences.cpp | 12 ++++++------ modules/libpref/goanna.js | 12 ++++++++++++ modules/libpref/greprefs.js | 12 ------------ modules/libpref/moz.build | 4 +--- python/mozbuild/mozpack/packager/formats.py | 2 +- python/mozbuild/mozpack/test/test_packager_formats.py | 4 ++-- toolkit/mozapps/update/tests/data/xpcshellUtilsAUS.js | 2 +- 7 files changed, 23 insertions(+), 25 deletions(-) create mode 100644 modules/libpref/goanna.js delete mode 100644 modules/libpref/greprefs.js diff --git a/modules/libpref/Preferences.cpp b/modules/libpref/Preferences.cpp index 19487704f..840406635 100644 --- a/modules/libpref/Preferences.cpp +++ b/modules/libpref/Preferences.cpp @@ -1229,10 +1229,10 @@ static nsresult pref_InitInitialObjects() nsresult rv; // In omni.jar case, we load the following prefs: - // - jar:$gre/omni.jar!/greprefs.js + // - jar:$gre/omni.jar!/goanna.js // - jar:$gre/omni.jar!/defaults/pref/*.js // In non omni.jar case, we load: - // - $gre/greprefs.js + // - $gre/goanna.js // // In both cases, we also load: // - $gre/defaults/pref/*.js @@ -1259,8 +1259,8 @@ static nsresult pref_InitInitialObjects() RefPtr jarReader = mozilla::Omnijar::GetReader(mozilla::Omnijar::GRE); if (jarReader) { - // Load jar:$gre/omni.jar!/greprefs.js - rv = pref_ReadPrefFromJar(jarReader, "greprefs.js"); + // Load jar:$gre/omni.jar!/goanna.js + rv = pref_ReadPrefFromJar(jarReader, "goanna.js"); NS_ENSURE_SUCCESS(rv, rv); // Load jar:$gre/omni.jar!/defaults/pref/*.js @@ -1279,12 +1279,12 @@ static nsresult pref_InitInitialObjects() NS_WARNING("Error parsing preferences."); } } else { - // Load $gre/greprefs.js + // Load $gre/goanna.js nsCOMPtr greprefsFile; rv = NS_GetSpecialDirectory(NS_GRE_DIR, getter_AddRefs(greprefsFile)); NS_ENSURE_SUCCESS(rv, rv); - rv = greprefsFile->AppendNative(NS_LITERAL_CSTRING("greprefs.js")); + rv = greprefsFile->AppendNative(NS_LITERAL_CSTRING("goanna.js")); NS_ENSURE_SUCCESS(rv, rv); rv = openPrefFile(greprefsFile); diff --git a/modules/libpref/goanna.js b/modules/libpref/goanna.js new file mode 100644 index 000000000..d59110b6a --- /dev/null +++ b/modules/libpref/goanna.js @@ -0,0 +1,12 @@ +#include ../../netwerk/base/security-prefs.js +#include init/all.js +#ifdef MOZ_DATA_REPORTING +#include ../../toolkit/components/telemetry/datareporting-prefs.js +#endif +#ifdef MOZ_SERVICES_HEALTHREPORT +#if MOZ_WIDGET_TOOLKIT == android +#include ../../mobile/android/chrome/content/healthreport-prefs.js +#else +#include ../../toolkit/components/telemetry/healthreport-prefs.js +#endif +#endif diff --git a/modules/libpref/greprefs.js b/modules/libpref/greprefs.js deleted file mode 100644 index d59110b6a..000000000 --- a/modules/libpref/greprefs.js +++ /dev/null @@ -1,12 +0,0 @@ -#include ../../netwerk/base/security-prefs.js -#include init/all.js -#ifdef MOZ_DATA_REPORTING -#include ../../toolkit/components/telemetry/datareporting-prefs.js -#endif -#ifdef MOZ_SERVICES_HEALTHREPORT -#if MOZ_WIDGET_TOOLKIT == android -#include ../../mobile/android/chrome/content/healthreport-prefs.js -#else -#include ../../toolkit/components/telemetry/healthreport-prefs.js -#endif -#endif diff --git a/modules/libpref/moz.build b/modules/libpref/moz.build index 1c2c13e69..1c9a51650 100644 --- a/modules/libpref/moz.build +++ b/modules/libpref/moz.build @@ -43,6 +43,4 @@ FINAL_LIBRARY = 'xul' DEFINES['OS_ARCH'] = CONFIG['OS_ARCH'] DEFINES['MOZ_WIDGET_TOOLKIT'] = CONFIG['MOZ_WIDGET_TOOLKIT'] -FINAL_TARGET_PP_FILES += [ - 'greprefs.js', -] +FINAL_TARGET_PP_FILES += ['goanna.js'] diff --git a/python/mozbuild/mozpack/packager/formats.py b/python/mozbuild/mozpack/packager/formats.py index c4adabab0..cedd1998b 100644 --- a/python/mozbuild/mozpack/packager/formats.py +++ b/python/mozbuild/mozpack/packager/formats.py @@ -318,7 +318,7 @@ class OmniJarSubFormatter(PiecemealFormatter): path[1] in ['pref', 'preferences']) return path[0] in [ 'modules', - 'greprefs.js', + 'goanna.js', 'hyphenation', 'update.locale', ] or path[0] in STARTUP_CACHE_PATHS diff --git a/python/mozbuild/mozpack/test/test_packager_formats.py b/python/mozbuild/mozpack/test/test_packager_formats.py index 1af4336b2..66a7cc8e6 100644 --- a/python/mozbuild/mozpack/test/test_packager_formats.py +++ b/python/mozbuild/mozpack/test/test_packager_formats.py @@ -405,13 +405,13 @@ class TestFormatters(unittest.TestCase): self.assertFalse( is_resource(base, 'defaults/preferences/channel-prefs.js')) self.assertTrue(is_resource(base, 'modules/foo.jsm')) - self.assertTrue(is_resource(base, 'greprefs.js')) + self.assertTrue(is_resource(base, 'goanna.js')) self.assertTrue(is_resource(base, 'hyphenation/foo')) self.assertTrue(is_resource(base, 'update.locale')) self.assertTrue( is_resource(base, 'jsloader/resource/gre/modules/foo.jsm')) self.assertFalse(is_resource(base, 'foo')) - self.assertFalse(is_resource(base, 'foo/bar/greprefs.js')) + self.assertFalse(is_resource(base, 'foo/bar/goanna.js')) self.assertTrue(is_resource(base, 'defaults/messenger/foo.dat')) self.assertFalse( is_resource(base, 'defaults/messenger/mailViews.dat')) diff --git a/toolkit/mozapps/update/tests/data/xpcshellUtilsAUS.js b/toolkit/mozapps/update/tests/data/xpcshellUtilsAUS.js index ada08f0ae..9a9610dda 100644 --- a/toolkit/mozapps/update/tests/data/xpcshellUtilsAUS.js +++ b/toolkit/mozapps/update/tests/data/xpcshellUtilsAUS.js @@ -839,7 +839,7 @@ function setupTestCommon() { if (!grePrefsFile.exists()) { grePrefsFile.create(Ci.nsIFile.DIRECTORY_TYPE, PERMS_DIRECTORY); } - grePrefsFile.append("greprefs.js"); + grePrefsFile.append("goanna.js"); if (!grePrefsFile.exists()) { grePrefsFile.create(Ci.nsILocalFile.NORMAL_FILE_TYPE, PERMS_FILE); } -- cgit v1.2.3 From 22198ec1941581b09dc4b3f76702a6b744eab818 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Sat, 18 Jan 2020 14:09:43 -0500 Subject: Issue #1358 - Default to SSL/TLS when using the Account Wizard --- mailnews/base/prefs/content/aw-incoming.js | 5 ++++- mailnews/mailnews.js | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/mailnews/base/prefs/content/aw-incoming.js b/mailnews/base/prefs/content/aw-incoming.js index fcc063fed..5ea0c77ae 100644 --- a/mailnews/base/prefs/content/aw-incoming.js +++ b/mailnews/base/prefs/content/aw-incoming.js @@ -158,7 +158,10 @@ function setServerType() var serverType = document.getElementById("servertype").value; var deferStorageBox = document.getElementById("deferStorageBox"); var leaveMessages = document.getElementById("leaveMsgsOnSrvrBox"); - var port = serverType == "pop3" ? 110 : 143; + + // pop3 110 (unsecure) 995 (SSL) + // imap 143 (unsecure) 993 (SSL) + var port = serverType == "pop3" ? 995 : 993; document.getElementById("serverPort").value = port; document.getElementById("defaultPortValue").value = port; diff --git a/mailnews/mailnews.js b/mailnews/mailnews.js index 705a0a08a..7ebe2eaa7 100644 --- a/mailnews/mailnews.js +++ b/mailnews/mailnews.js @@ -450,7 +450,7 @@ pref("mail.server.default.valid", true); pref("mail.server.default.abbreviate", true); pref("mail.server.default.isSecure", false); pref("mail.server.default.authMethod", 3); // cleartext password. @see nsIMsgIncomingServer.authMethod. -pref("mail.server.default.socketType", 0); // @see nsIMsgIncomingServer.socketType +pref("mail.server.default.socketType", 3); // SSL/TLS. @see nsIMsgIncomingServer.socketType pref("mail.server.default.override_namespaces", true); pref("mail.server.default.deferred_to_account", ""); @@ -579,7 +579,7 @@ pref("mail.smtp.useMatchingDomainServer", false); pref("mail.smtp.useMatchingHostNameServer", false); pref("mail.smtpserver.default.authMethod", 3); // cleartext password. @see nsIMsgIncomingServer.authMethod. -pref("mail.smtpserver.default.try_ssl", 0); // @see nsISmtpServer.socketType +pref("mail.smtpserver.default.try_ssl", 3); // SSL/TLS. @see nsISmtpServer.socketType // For the next 3 prefs, see pref("mail.display_glyph", true); // TXT->HTML :-) etc. in viewer -- cgit v1.2.3 From b1abb9aebe9de3507c93f31cf1b7ffff3432e481 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Sun, 19 Jan 2020 14:35:28 +0100 Subject: Issue #1362 - Revert "Update js/src/builtin/TestingFunctions.cpp for regex lookbehind changes" This reverts commit e79607a7a694dc2d48d65697b48138fa585145c9. --- js/src/builtin/TestingFunctions.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/js/src/builtin/TestingFunctions.cpp b/js/src/builtin/TestingFunctions.cpp index a9a307da7..025620766 100644 --- a/js/src/builtin/TestingFunctions.cpp +++ b/js/src/builtin/TestingFunctions.cpp @@ -3862,10 +3862,10 @@ ConvertRegExpTreeToObject(JSContext* cx, irregexp::RegExpTree* tree) return nullptr; return obj; } - if (tree->IsLookaround()) { - if (!StringProp(cx, obj, "type", "Lookaround")) + if (tree->IsLookahead()) { + if (!StringProp(cx, obj, "type", "Lookahead")) return nullptr; - irregexp::RegExpLookaround* t = tree->AsLookaround(); + irregexp::RegExpLookahead* t = tree->AsLookahead(); if (!BooleanProp(cx, obj, "is_positive", t->is_positive())) return nullptr; if (!TreeProp(cx, obj, "body", t->body())) -- cgit v1.2.3 From e0baeba546f8f45bc1ec981a60b615a28f4142af Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Sun, 19 Jan 2020 14:38:36 +0100 Subject: Issue #1362 - Revert "Implement regular expression lookbehind" This reverts commit fa473930f424bf17a9e545b601c84dd2e61364e3. --- js/src/irregexp/NativeRegExpMacroAssembler.cpp | 8 +- js/src/irregexp/NativeRegExpMacroAssembler.h | 7 +- js/src/irregexp/RegExpAST.cpp | 8 +- js/src/irregexp/RegExpAST.h | 33 ++---- js/src/irregexp/RegExpBytecode.h | 23 ++-- js/src/irregexp/RegExpEngine.cpp | 151 +++++++++---------------- js/src/irregexp/RegExpEngine.h | 31 ++--- js/src/irregexp/RegExpInterpreter.cpp | 74 +----------- js/src/irregexp/RegExpMacroAssembler.cpp | 17 +-- js/src/irregexp/RegExpMacroAssembler.h | 15 ++- js/src/irregexp/RegExpParser.cpp | 130 +++++++-------------- js/src/irregexp/RegExpParser.h | 19 +--- 12 files changed, 157 insertions(+), 359 deletions(-) diff --git a/js/src/irregexp/NativeRegExpMacroAssembler.cpp b/js/src/irregexp/NativeRegExpMacroAssembler.cpp index e17eecb9b..0fb507297 100644 --- a/js/src/irregexp/NativeRegExpMacroAssembler.cpp +++ b/js/src/irregexp/NativeRegExpMacroAssembler.cpp @@ -582,7 +582,7 @@ NativeRegExpMacroAssembler::CheckAtStart(Label* on_at_start) } void -NativeRegExpMacroAssembler::CheckNotAtStart(int cp_offset, Label* on_not_at_start) +NativeRegExpMacroAssembler::CheckNotAtStart(Label* on_not_at_start) { JitSpew(SPEW_PREFIX "CheckNotAtStart"); @@ -673,7 +673,7 @@ NativeRegExpMacroAssembler::CheckGreedyLoop(Label* on_tos_equals_current_positio } void -NativeRegExpMacroAssembler::CheckNotBackReference(int start_reg, bool read_backward, Label* on_no_match) +NativeRegExpMacroAssembler::CheckNotBackReference(int start_reg, Label* on_no_match) { JitSpew(SPEW_PREFIX "CheckNotBackReference(%d)", start_reg); @@ -744,8 +744,8 @@ NativeRegExpMacroAssembler::CheckNotBackReference(int start_reg, bool read_backw } void -NativeRegExpMacroAssembler::CheckNotBackReferenceIgnoreCase(int start_reg, bool read_backward, - Label* on_no_match, bool unicode) +NativeRegExpMacroAssembler::CheckNotBackReferenceIgnoreCase(int start_reg, Label* on_no_match, + bool unicode) { JitSpew(SPEW_PREFIX "CheckNotBackReferenceIgnoreCase(%d, %d)", start_reg, unicode); diff --git a/js/src/irregexp/NativeRegExpMacroAssembler.h b/js/src/irregexp/NativeRegExpMacroAssembler.h index fc582dccf..7a72e252f 100644 --- a/js/src/irregexp/NativeRegExpMacroAssembler.h +++ b/js/src/irregexp/NativeRegExpMacroAssembler.h @@ -105,10 +105,9 @@ class MOZ_STACK_CLASS NativeRegExpMacroAssembler final : public RegExpMacroAssem void CheckCharacterGT(char16_t limit, jit::Label* on_greater); void CheckCharacterLT(char16_t limit, jit::Label* on_less); void CheckGreedyLoop(jit::Label* on_tos_equals_current_position); - void CheckNotAtStart(int cp_offset, jit::Label* on_not_at_start); - void CheckNotBackReference(int start_reg, bool read_backward, jit::Label* on_no_match); - void CheckNotBackReferenceIgnoreCase(int start_reg, bool read_backward, - jit::Label* on_no_match, bool unicode); + void CheckNotAtStart(jit::Label* on_not_at_start); + void CheckNotBackReference(int start_reg, jit::Label* on_no_match); + void CheckNotBackReferenceIgnoreCase(int start_reg, jit::Label* on_no_match, bool unicode); void CheckNotCharacter(unsigned c, jit::Label* on_not_equal); void CheckNotCharacterAfterAnd(unsigned c, unsigned and_with, jit::Label* on_not_equal); void CheckNotCharacterAfterMinusAnd(char16_t c, char16_t minus, char16_t and_with, diff --git a/js/src/irregexp/RegExpAST.cpp b/js/src/irregexp/RegExpAST.cpp index 43867c312..8dfd99057 100644 --- a/js/src/irregexp/RegExpAST.cpp +++ b/js/src/irregexp/RegExpAST.cpp @@ -250,16 +250,16 @@ RegExpCapture::CaptureRegisters() } // ---------------------------------------------------------------------------- -// RegExpLookaround +// RegExpLookahead Interval -RegExpLookaround::CaptureRegisters() +RegExpLookahead::CaptureRegisters() { return body()->CaptureRegisters(); } bool -RegExpLookaround::IsAnchoredAtStart() +RegExpLookahead::IsAnchoredAtStart() { - return is_positive() && type() == LOOKAHEAD && body()->IsAnchoredAtStart(); + return is_positive() && body()->IsAnchoredAtStart(); } diff --git a/js/src/irregexp/RegExpAST.h b/js/src/irregexp/RegExpAST.h index 6f59842bc..7bda6fc7e 100644 --- a/js/src/irregexp/RegExpAST.h +++ b/js/src/irregexp/RegExpAST.h @@ -360,7 +360,6 @@ class RegExpCapture : public RegExpTree virtual int min_match() { return body_->min_match(); } virtual int max_match() { return body_->max_match(); } RegExpTree* body() { return body_; } - void set_body(RegExpTree* body) { body_ = body; } int index() { return index_; } static int StartRegister(int index) { return index * 2; } static int EndRegister(int index) { return index * 2 + 1; } @@ -370,29 +369,25 @@ class RegExpCapture : public RegExpTree int index_; }; -class RegExpLookaround : public RegExpTree +class RegExpLookahead : public RegExpTree { public: - enum Type { LOOKAHEAD, LOOKBEHIND }; - - RegExpLookaround(RegExpTree* body, - bool is_positive, - int capture_count, - int capture_from, - Type type) + RegExpLookahead(RegExpTree* body, + bool is_positive, + int capture_count, + int capture_from) : body_(body), is_positive_(is_positive), capture_count_(capture_count), - capture_from_(capture_from), - type_(type) + capture_from_(capture_from) {} virtual void* Accept(RegExpVisitor* visitor, void* data); virtual RegExpNode* ToNode(RegExpCompiler* compiler, RegExpNode* on_success); - virtual RegExpLookaround* AsLookaround(); + virtual RegExpLookahead* AsLookahead(); virtual Interval CaptureRegisters(); - virtual bool IsLookaround(); + virtual bool IsLookahead(); virtual bool IsAnchoredAtStart(); virtual int min_match() { return 0; } virtual int max_match() { return 0; } @@ -400,14 +395,12 @@ class RegExpLookaround : public RegExpTree bool is_positive() { return is_positive_; } int capture_count() { return capture_count_; } int capture_from() { return capture_from_; } - Type type() { return type_; } private: RegExpTree* body_; bool is_positive_; int capture_count_; int capture_from_; - Type type_; }; typedef InfallibleVector RegExpCaptureVector; @@ -424,14 +417,8 @@ class RegExpBackReference : public RegExpTree RegExpNode* on_success); virtual RegExpBackReference* AsBackReference(); virtual bool IsBackReference(); - virtual int min_match() override { return 0; } - // The capture may not be completely parsed yet, if the reference occurs - // before the capture. In the ordinary case, nothing has been captured yet, - // so the back reference must have the length 0. If the back reference is - // inside a lookbehind, effectively making it a forward reference, we return - virtual int max_match() override { - return capture_->body() ? capture_->max_match() : 0; - } + virtual int min_match() { return 0; } + virtual int max_match() { return capture_->max_match(); } int index() { return capture_->index(); } RegExpCapture* capture() { return capture_; } private: diff --git a/js/src/irregexp/RegExpBytecode.h b/js/src/irregexp/RegExpBytecode.h index ea3f80b4f..f31b78c59 100644 --- a/js/src/irregexp/RegExpBytecode.h +++ b/js/src/irregexp/RegExpBytecode.h @@ -82,19 +82,16 @@ V(CHECK_LT, 35, 8) /* bc8 pad8 uc16 addr32 */ \ V(CHECK_GT, 36, 8) /* bc8 pad8 uc16 addr32 */ \ V(CHECK_NOT_BACK_REF, 37, 8) /* bc8 reg_idx24 addr32 */ \ V(CHECK_NOT_BACK_REF_NO_CASE, 38, 8) /* bc8 reg_idx24 addr32 */ \ -V(CHECK_NOT_BACK_REF_BACKWARD, 39, 8) /* bc8 reg_idx24 addr32 */ \ -V(CHECK_NOT_BACK_REF_NO_CASE_BACKWARD, 40, 8) /* bc8 reg_idx24 addr32 */ \ -V(CHECK_NOT_REGS_EQUAL, 41, 12) /* bc8 regidx24 reg_idx32 addr32 */ \ -V(CHECK_REGISTER_LT, 42, 12) /* bc8 reg_idx24 value32 addr32 */ \ -V(CHECK_REGISTER_GE, 43, 12) /* bc8 reg_idx24 value32 addr32 */ \ -V(CHECK_REGISTER_EQ_POS, 44, 8) /* bc8 reg_idx24 addr32 */ \ -V(CHECK_AT_START, 45, 8) /* bc8 pad24 addr32 */ \ -V(CHECK_NOT_AT_START, 46, 8) /* bc8 pad24 addr32 */ \ -V(CHECK_GREEDY, 47, 8) /* bc8 pad24 addr32 */ \ -V(ADVANCE_CP_AND_GOTO, 48, 8) /* bc8 offset24 addr32 */ \ -V(SET_CURRENT_POSITION_FROM_END, 49, 4) /* bc8 idx24 */ \ -V(CHECK_NOT_BACK_REF_NO_CASE_UNICODE, 50, 8) /* bc8 reg_idx24 addr32 */ \ -V(CHECK_NOT_BACK_REF_NO_CASE_BACKWARD_UNICODE, 51, 8) /* bc8 reg_idx24 addr32 */ +V(CHECK_NOT_REGS_EQUAL, 39, 12) /* bc8 regidx24 reg_idx32 addr32 */ \ +V(CHECK_REGISTER_LT, 40, 12) /* bc8 reg_idx24 value32 addr32 */ \ +V(CHECK_REGISTER_GE, 41, 12) /* bc8 reg_idx24 value32 addr32 */ \ +V(CHECK_REGISTER_EQ_POS, 42, 8) /* bc8 reg_idx24 addr32 */ \ +V(CHECK_AT_START, 43, 8) /* bc8 pad24 addr32 */ \ +V(CHECK_NOT_AT_START, 44, 8) /* bc8 pad24 addr32 */ \ +V(CHECK_GREEDY, 45, 8) /* bc8 pad24 addr32 */ \ +V(ADVANCE_CP_AND_GOTO, 46, 8) /* bc8 offset24 addr32 */ \ +V(SET_CURRENT_POSITION_FROM_END, 47, 4) /* bc8 idx24 */ \ +V(CHECK_NOT_BACK_REF_NO_CASE_UNICODE, 48, 8) /* bc8 reg_idx24 addr32 */ #define DECLARE_BYTECODES(name, code, length) \ static const int BC_##name = code; diff --git a/js/src/irregexp/RegExpEngine.cpp b/js/src/irregexp/RegExpEngine.cpp index 62f94c3e7..4d691a5dc 100644 --- a/js/src/irregexp/RegExpEngine.cpp +++ b/js/src/irregexp/RegExpEngine.cpp @@ -721,8 +721,6 @@ ActionNode::EmptyMatchCheck(int start_register, int TextNode::EatsAtLeast(int still_to_find, int budget, bool not_at_start) { - if (read_backward()) - return 0; int answer = Length(); if (answer >= still_to_find) return answer; @@ -738,7 +736,8 @@ TextNode::EatsAtLeast(int still_to_find, int budget, bool not_at_start) int TextNode::GreedyLoopTextLength() { - return Length(); + TextElement elm = elements()[elements().length() - 1]; + return elm.cp_offset() + elm.length(); } RegExpNode* @@ -888,8 +887,6 @@ AssertionNode::FillInBMInfo(int offset, int budget, BoyerMooreLookahead* bm, boo int BackReferenceNode::EatsAtLeast(int still_to_find, int budget, bool not_at_start) { - if (read_backward()) - return 0; if (budget <= 0) return 0; return on_success()->EatsAtLeast(still_to_find, budget - 1, not_at_start); @@ -1581,9 +1578,6 @@ class irregexp::RegExpCompiler current_expansion_factor_ = value; } - bool read_backward() { return read_backward_; } - void set_read_backward(bool value) { read_backward_ = value; } - JSContext* cx() const { return cx_; } LifoAlloc* alloc() const { return alloc_; } @@ -1601,7 +1595,6 @@ class irregexp::RegExpCompiler bool unicode_; bool reg_exp_too_big_; int current_expansion_factor_; - bool read_backward_; FrequencyCollator frequency_collator_; JSContext* cx_; LifoAlloc* alloc_; @@ -1631,7 +1624,6 @@ RegExpCompiler::RegExpCompiler(JSContext* cx, LifoAlloc* alloc, int capture_coun unicode_(unicode), reg_exp_too_big_(false), current_expansion_factor_(1), - read_backward_(false), frequency_collator_(), cx_(cx), alloc_(alloc) @@ -1755,7 +1747,7 @@ irregexp::CompilePattern(JSContext* cx, RegExpShared* shared, RegExpCompileData* // at the start of input. ChoiceNode* first_step_node = alloc.newInfallible(&alloc, 2); RegExpNode* char_class = - alloc.newInfallible(alloc.newInfallible('*'), false, loop_node); + alloc.newInfallible(alloc.newInfallible('*'), loop_node); first_step_node->AddAlternative(GuardedAlternative(captured_body)); first_step_node->AddAlternative(GuardedAlternative(char_class)); node = first_step_node; @@ -1858,19 +1850,19 @@ RegExpAtom::ToNode(RegExpCompiler* compiler, RegExpNode* on_success) TextElementVector* elms = compiler->alloc()->newInfallible(*compiler->alloc()); elms->append(TextElement::Atom(this)); - return compiler->alloc()->newInfallible(elms, compiler->read_backward(), on_success); + return compiler->alloc()->newInfallible(elms, on_success); } RegExpNode* RegExpText::ToNode(RegExpCompiler* compiler, RegExpNode* on_success) { - return compiler->alloc()->newInfallible(&elements_, compiler->read_backward(), on_success); + return compiler->alloc()->newInfallible(&elements_, on_success); } RegExpNode* RegExpCharacterClass::ToNode(RegExpCompiler* compiler, RegExpNode* on_success) { - return compiler->alloc()->newInfallible(this, compiler->read_backward(), on_success); + return compiler->alloc()->newInfallible(this, on_success); } RegExpNode* @@ -2011,8 +2003,7 @@ RegExpQuantifier::ToNode(int min, alternation->AddAlternative(GuardedAlternative(body->ToNode(compiler, answer))); } answer = alternation; - if (not_at_start && !compiler->read_backward()) - alternation->set_not_at_start(); + if (not_at_start) alternation->set_not_at_start(); } return answer; } @@ -2024,9 +2015,8 @@ RegExpQuantifier::ToNode(int min, int reg_ctr = needs_counter ? compiler->AllocateRegister() : RegExpCompiler::kNoRegister; - LoopChoiceNode* center = alloc->newInfallible(alloc, body->min_match() == 0, - compiler->read_backward()); - if (not_at_start && !compiler->read_backward()) + LoopChoiceNode* center = alloc->newInfallible(alloc, body->min_match() == 0); + if (not_at_start) center->set_not_at_start(); RegExpNode* loop_return = needs_counter ? static_cast(ActionNode::IncrementRegister(reg_ctr, center)) @@ -2102,7 +2092,7 @@ RegExpAssertion::ToNode(RegExpCompiler* compiler, CharacterRange::AddClassEscape(alloc, 'n', newline_ranges); RegExpCharacterClass* newline_atom = alloc->newInfallible('n'); TextNode* newline_matcher = - alloc->newInfallible(newline_atom, false, + alloc->newInfallible(newline_atom, ActionNode::PositiveSubmatchSuccess(stack_pointer_register, position_register, 0, // No captures inside. @@ -2134,7 +2124,6 @@ RegExpBackReference::ToNode(RegExpCompiler* compiler, RegExpNode* on_success) { return compiler->alloc()->newInfallible(RegExpCapture::StartRegister(index()), RegExpCapture::EndRegister(index()), - compiler->read_backward(), on_success); } @@ -2145,7 +2134,7 @@ RegExpEmpty::ToNode(RegExpCompiler* compiler, RegExpNode* on_success) } RegExpNode* -RegExpLookaround::ToNode(RegExpCompiler* compiler, RegExpNode* on_success) +RegExpLookahead::ToNode(RegExpCompiler* compiler, RegExpNode* on_success) { int stack_pointer_register = compiler->AllocateRegister(); int position_register = compiler->AllocateRegister(); @@ -2156,10 +2145,6 @@ RegExpLookaround::ToNode(RegExpCompiler* compiler, RegExpNode* on_success) int register_start = register_of_first_capture + capture_from_ * registers_per_capture; - RegExpNode* result; - bool was_reading_backward = compiler->read_backward(); - compiler->set_read_backward(type() == LOOKBEHIND); - if (is_positive()) { RegExpNode* bodyNode = body()->ToNode(compiler, @@ -2168,39 +2153,37 @@ RegExpLookaround::ToNode(RegExpCompiler* compiler, RegExpNode* on_success) register_count, register_start, on_success)); - result = ActionNode::BeginSubmatch(stack_pointer_register, - position_register, - bodyNode); - } else { - // We use a ChoiceNode for a negative lookahead because it has most of - // the characteristics we need. It has the body of the lookahead as its - // first alternative and the expression after the lookahead of the second - // alternative. If the first alternative succeeds then the - // NegativeSubmatchSuccess will unwind the stack including everything the - // choice node set up and backtrack. If the first alternative fails then - // the second alternative is tried, which is exactly the desired result - // for a negative lookahead. The NegativeLookaheadChoiceNode is a special - // ChoiceNode that knows to ignore the first exit when calculating quick - // checks. - LifoAlloc* alloc = compiler->alloc(); - - RegExpNode* success = - alloc->newInfallible(alloc, - stack_pointer_register, - position_register, - register_count, - register_start); - GuardedAlternative body_alt(body()->ToNode(compiler, success)); - - ChoiceNode* choice_node = - alloc->newInfallible(alloc, body_alt, GuardedAlternative(on_success)); - - result = ActionNode::BeginSubmatch(stack_pointer_register, + return ActionNode::BeginSubmatch(stack_pointer_register, position_register, - choice_node); - } - compiler->set_read_backward(was_reading_backward); - return result; + bodyNode); + } + + // We use a ChoiceNode for a negative lookahead because it has most of + // the characteristics we need. It has the body of the lookahead as its + // first alternative and the expression after the lookahead of the second + // alternative. If the first alternative succeeds then the + // NegativeSubmatchSuccess will unwind the stack including everything the + // choice node set up and backtrack. If the first alternative fails then + // the second alternative is tried, which is exactly the desired result + // for a negative lookahead. The NegativeLookaheadChoiceNode is a special + // ChoiceNode that knows to ignore the first exit when calculating quick + // checks. + LifoAlloc* alloc = compiler->alloc(); + + RegExpNode* success = + alloc->newInfallible(alloc, + stack_pointer_register, + position_register, + register_count, + register_start); + GuardedAlternative body_alt(body()->ToNode(compiler, success)); + + ChoiceNode* choice_node = + alloc->newInfallible(alloc, body_alt, GuardedAlternative(on_success)); + + return ActionNode::BeginSubmatch(stack_pointer_register, + position_register, + choice_node); } RegExpNode* @@ -2215,14 +2198,8 @@ RegExpCapture::ToNode(RegExpTree* body, RegExpCompiler* compiler, RegExpNode* on_success) { - MOZ_ASSERT(body); int start_reg = RegExpCapture::StartRegister(index); int end_reg = RegExpCapture::EndRegister(index); - if (compiler->read_backward()) { - // std::swap(start_reg, end_reg); - start_reg = RegExpCapture::EndRegister(index); - end_reg = RegExpCapture::StartRegister(index); - } RegExpNode* store_end = ActionNode::StorePosition(end_reg, true, on_success); RegExpNode* body_node = body->ToNode(compiler, store_end); return ActionNode::StorePosition(start_reg, true, body_node); @@ -2233,15 +2210,8 @@ RegExpAlternative::ToNode(RegExpCompiler* compiler, RegExpNode* on_success) { const RegExpTreeVector& children = nodes(); RegExpNode* current = on_success; - if (compiler->read_backward()) { - for (int i = 0; i < children.length(); i++) { - current = children[i]->ToNode(compiler, current); - } - } else { - for (int i = children.length() - 1; i >= 0; i--) { - current = children[i]->ToNode(compiler, current); - } - } + for (int i = children.length() - 1; i >= 0; i--) + current = children[i]->ToNode(compiler, current); return current; } @@ -2794,6 +2764,7 @@ Trace::InvalidateCurrentCharacter() void Trace::AdvanceCurrentPositionInTrace(int by, RegExpCompiler* compiler) { + MOZ_ASSERT(by > 0); // We don't have an instruction for shifting the current character register // down or for using a shifted value for anything so lets just forget that // we preloaded any characters into it. @@ -3138,9 +3109,9 @@ AssertionNode::Emit(RegExpCompiler* compiler, Trace* trace) return; } if (trace->at_start() == Trace::UNKNOWN) { - assembler->CheckNotAtStart(trace->cp_offset(), trace->backtrack()); + assembler->CheckNotAtStart(trace->backtrack()); Trace at_start_trace = *trace; - at_start_trace.set_at_start(Trace::TRUE_VALUE); + at_start_trace.set_at_start(true); on_success()->Emit(compiler, &at_start_trace); return; } @@ -3843,10 +3814,9 @@ TextNode::TextEmitPass(RegExpCompiler* compiler, jit::Label* backtrack = trace->backtrack(); QuickCheckDetails* quick_check = trace->quick_check_performed(); int element_count = elements().length(); - int backward_offset = read_backward() ? -Length() : 0; for (int i = preloaded ? 0 : element_count - 1; i >= 0; i--) { TextElement elm = elements()[i]; - int cp_offset = trace->cp_offset() + elm.cp_offset() + backward_offset; + int cp_offset = trace->cp_offset() + elm.cp_offset(); if (elm.text_type() == TextElement::ATOM) { const CharacterVector& quarks = elm.atom()->data(); for (int j = preloaded ? 0 : quarks.length() - 1; j >= 0; j--) { @@ -3874,12 +3844,11 @@ TextNode::TextEmitPass(RegExpCompiler* compiler, break; } if (emit_function != nullptr) { - bool bounds_check = *checked_up_to < cp_offset + j || read_backward(); bool bound_checked = emit_function(compiler, quarks[j], backtrack, cp_offset + j, - bounds_check, + *checked_up_to < cp_offset + j, preloaded); if (bound_checked) UpdateBoundsCheck(cp_offset + j, checked_up_to); } @@ -3890,14 +3859,13 @@ TextNode::TextEmitPass(RegExpCompiler* compiler, if (first_element_checked && i == 0) continue; if (DeterminedAlready(quick_check, elm.cp_offset())) continue; RegExpCharacterClass* cc = elm.char_class(); - bool bounds_check = *checked_up_to < cp_offset || read_backward(); EmitCharClass(alloc(), assembler, cc, ascii, backtrack, cp_offset, - bounds_check, + *checked_up_to < cp_offset, preloaded); UpdateBoundsCheck(cp_offset, checked_up_to); } @@ -3977,11 +3945,8 @@ TextNode::Emit(RegExpCompiler* compiler, Trace* trace) } Trace successor_trace(*trace); - // If we advance backward, we may end up at the start. - successor_trace.AdvanceCurrentPositionInTrace( - read_backward() ? -Length() : Length(), compiler); - successor_trace.set_at_start(read_backward() ? Trace::UNKNOWN - : Trace::FALSE_VALUE); + successor_trace.set_at_start(false); + successor_trace.AdvanceCurrentPositionInTrace(Length(), compiler); RecursionCheck rc(compiler); on_success()->Emit(compiler, &successor_trace); } @@ -4153,8 +4118,6 @@ ChoiceNode::CalculatePreloadCharacters(RegExpCompiler* compiler, int eats_at_lea RegExpNode* TextNode::GetSuccessorOfOmnivorousTextNode(RegExpCompiler* compiler) { - if (read_backward()) return NULL; - if (elements().length() != 1) return nullptr; @@ -4202,7 +4165,7 @@ ChoiceNode::GreedyLoopTextLengthForAlternative(GuardedAlternative* alternative) SeqRegExpNode* seq_node = static_cast(node); node = seq_node->on_success(); } - return read_backward() ? -length : length; + return length; } // Creates a list of AlternativeGenerations. If the list has a reasonable @@ -4277,7 +4240,7 @@ ChoiceNode::Emit(RegExpCompiler* compiler, Trace* trace) jit::Label greedy_loop_label; Trace counter_backtrack_trace; counter_backtrack_trace.set_backtrack(&greedy_loop_label); - if (not_at_start()) counter_backtrack_trace.set_at_start(Trace::FALSE_VALUE); + if (not_at_start()) counter_backtrack_trace.set_at_start(false); if (choice_count > 1 && text_length != kNodeIsTooComplexForGreedyLoops) { // Here we have special handling for greedy loops containing only text nodes @@ -4293,7 +4256,7 @@ ChoiceNode::Emit(RegExpCompiler* compiler, Trace* trace) current_trace = &counter_backtrack_trace; jit::Label greedy_match_failed; Trace greedy_match_trace; - if (not_at_start()) greedy_match_trace.set_at_start(Trace::FALSE_VALUE); + if (not_at_start()) greedy_match_trace.set_at_start(false); greedy_match_trace.set_backtrack(&greedy_match_failed); jit::Label loop_label; macro_assembler->Bind(&loop_label); @@ -4642,14 +4605,11 @@ BackReferenceNode::Emit(RegExpCompiler* compiler, Trace* trace) MOZ_ASSERT(start_reg_ + 1 == end_reg_); if (compiler->ignore_case()) { assembler->CheckNotBackReferenceIgnoreCase(start_reg_, - read_backward(), trace->backtrack(), compiler->unicode()); } else { - assembler->CheckNotBackReference(start_reg_, read_backward(), trace->backtrack()); + assembler->CheckNotBackReference(start_reg_, trace->backtrack()); } - // We are going to advance backward, so we may end up at the start. - if (read_backward()) trace->set_at_start(Trace::UNKNOWN); on_success()->Emit(compiler, trace); } @@ -5017,6 +4977,7 @@ QuickCheckDetails::Clear() void QuickCheckDetails::Advance(int by, bool ascii) { + MOZ_ASSERT(by >= 0); if (by >= characters_) { Clear(); return; diff --git a/js/src/irregexp/RegExpEngine.h b/js/src/irregexp/RegExpEngine.h index c4409dcca..1a8fd4b22 100644 --- a/js/src/irregexp/RegExpEngine.h +++ b/js/src/irregexp/RegExpEngine.h @@ -119,7 +119,7 @@ InterpretCode(JSContext* cx, const uint8_t* byteCode, const CharT* chars, size_t VISIT(Atom) \ VISIT(Quantifier) \ VISIT(Capture) \ - VISIT(Lookaround) \ + VISIT(Lookahead) \ VISIT(BackReference) \ VISIT(Empty) \ VISIT(Text) @@ -763,19 +763,15 @@ class TextNode : public SeqRegExpNode { public: TextNode(TextElementVector* elements, - bool read_backward, RegExpNode* on_success) : SeqRegExpNode(on_success), - elements_(elements), - read_backward_(read_backward) + elements_(elements) {} TextNode(RegExpCharacterClass* that, - bool read_backward, RegExpNode* on_success) : SeqRegExpNode(on_success), - elements_(alloc()->newInfallible(*alloc())), - read_backward_(read_backward) + elements_(alloc()->newInfallible(*alloc())) { elements_->append(TextElement::CharClass(that)); } @@ -788,7 +784,6 @@ class TextNode : public SeqRegExpNode int characters_filled_in, bool not_at_start); TextElementVector& elements() { return *elements_; } - bool read_backward() { return read_backward_; } void MakeCaseIndependent(bool is_ascii, bool unicode); virtual int GreedyLoopTextLength(); virtual RegExpNode* GetSuccessorOfOmnivorousTextNode( @@ -819,7 +814,6 @@ class TextNode : public SeqRegExpNode int* checked_up_to); int Length(); TextElementVector* elements_; - bool read_backward_; }; class AssertionNode : public SeqRegExpNode @@ -888,18 +882,15 @@ class BackReferenceNode : public SeqRegExpNode public: BackReferenceNode(int start_reg, int end_reg, - bool read_backward, RegExpNode* on_success) : SeqRegExpNode(on_success), start_reg_(start_reg), - end_reg_(end_reg), - read_backward_(read_backward) + end_reg_(end_reg) {} virtual void Accept(NodeVisitor* visitor); int start_register() { return start_reg_; } int end_register() { return end_reg_; } - bool read_backward() { return read_backward_; } virtual void Emit(RegExpCompiler* compiler, Trace* trace); virtual int EatsAtLeast(int still_to_find, int recursion_depth, @@ -918,7 +909,6 @@ class BackReferenceNode : public SeqRegExpNode private: int start_reg_; int end_reg_; - bool read_backward_; }; class EndNode : public RegExpNode @@ -1063,7 +1053,6 @@ class ChoiceNode : public RegExpNode void set_being_calculated(bool b) { being_calculated_ = b; } virtual bool try_to_emit_quick_check_for_alternative(int i) { return true; } virtual RegExpNode* FilterASCII(int depth, bool ignore_case, bool unicode); - virtual bool read_backward() { return false; } protected: int GreedyLoopTextLengthForAlternative(GuardedAlternative* alternative); @@ -1122,13 +1111,11 @@ class NegativeLookaheadChoiceNode : public ChoiceNode class LoopChoiceNode : public ChoiceNode { public: - explicit LoopChoiceNode(LifoAlloc* alloc, bool body_can_be_zero_length, - bool read_backward) + explicit LoopChoiceNode(LifoAlloc* alloc, bool body_can_be_zero_length) : ChoiceNode(alloc, 2), loop_node_(nullptr), continue_node_(nullptr), - body_can_be_zero_length_(body_can_be_zero_length), - read_backward_(read_backward) + body_can_be_zero_length_(body_can_be_zero_length) {} void AddLoopAlternative(GuardedAlternative alt); @@ -1146,7 +1133,6 @@ class LoopChoiceNode : public ChoiceNode RegExpNode* loop_node() { return loop_node_; } RegExpNode* continue_node() { return continue_node_; } bool body_can_be_zero_length() { return body_can_be_zero_length_; } - virtual bool read_backward() { return read_backward_; } virtual void Accept(NodeVisitor* visitor); virtual RegExpNode* FilterASCII(int depth, bool ignore_case, bool unicode); @@ -1161,7 +1147,6 @@ class LoopChoiceNode : public ChoiceNode RegExpNode* loop_node_; RegExpNode* continue_node_; bool body_can_be_zero_length_; - bool read_backward_; }; // Improve the speed that we scan for an initial point where a non-anchored @@ -1437,8 +1422,8 @@ class Trace } TriBool at_start() { return at_start_; } - void set_at_start(TriBool at_start) { - at_start_ = at_start; + void set_at_start(bool at_start) { + at_start_ = at_start ? TRUE_VALUE : FALSE_VALUE; } jit::Label* backtrack() { return backtrack_; } jit::Label* loop_label() { return loop_label_; } diff --git a/js/src/irregexp/RegExpInterpreter.cpp b/js/src/irregexp/RegExpInterpreter.cpp index d09b4671e..7fd2d983a 100644 --- a/js/src/irregexp/RegExpInterpreter.cpp +++ b/js/src/irregexp/RegExpInterpreter.cpp @@ -222,8 +222,8 @@ irregexp::InterpretCode(JSContext* cx, const uint8_t* byteCode, const CharT* cha } break; BYTECODE(LOAD_CURRENT_CHAR) { - int pos = current + (insn >> BYTECODE_SHIFT); - if (pos >= (int)length || pos < 0) { + size_t pos = current + (insn >> BYTECODE_SHIFT); + if (pos >= length) { pc = byteCode + Load32Aligned(pc + 4); } else { current_char = chars[pos]; @@ -238,8 +238,8 @@ irregexp::InterpretCode(JSContext* cx, const uint8_t* byteCode, const CharT* cha break; } BYTECODE(LOAD_2_CURRENT_CHARS) { - int pos = current + (insn >> BYTECODE_SHIFT); - if (pos + 2 > (int)length || pos < 0) { + size_t pos = current + (insn >> BYTECODE_SHIFT); + if (pos + 2 > length) { pc = byteCode + Load32Aligned(pc + 4); } else { CharT next = chars[pos + 1]; @@ -425,30 +425,6 @@ irregexp::InterpretCode(JSContext* cx, const uint8_t* byteCode, const CharT* cha pc += BC_CHECK_NOT_BACK_REF_LENGTH; break; } - BYTECODE(CHECK_NOT_BACK_REF_BACKWARD) { - int from = registers[insn >> BYTECODE_SHIFT]; - int len = registers[(insn >> BYTECODE_SHIFT) + 1] - from; - if (from < 0 || len <= 0) { - pc += BC_CHECK_NOT_BACK_REF_BACKWARD_LENGTH; - break; - } - if (int(current) - len < 0) { - pc = byteCode + Load32Aligned(pc + 4); - break; - } else { - int i; - for (i = 0; i < len; i++) { - if (chars[from + i] != chars[int(current) - len + i]) { - pc = byteCode + Load32Aligned(pc + 4); - break; - } - } - if (i < len) break; - current -= len; - } - pc += BC_CHECK_NOT_BACK_REF_BACKWARD_LENGTH; - break; - } BYTECODE(CHECK_NOT_BACK_REF_NO_CASE) { int from = registers[insn >> BYTECODE_SHIFT]; int len = registers[(insn >> BYTECODE_SHIFT) + 1] - from; @@ -489,46 +465,6 @@ irregexp::InterpretCode(JSContext* cx, const uint8_t* byteCode, const CharT* cha } break; } - BYTECODE(CHECK_NOT_BACK_REF_NO_CASE_BACKWARD) { - int from = registers[insn >> BYTECODE_SHIFT]; - int len = registers[(insn >> BYTECODE_SHIFT) + 1] - from; - if (from < 0 || len <= 0) { - pc += BC_CHECK_NOT_BACK_REF_NO_CASE_BACKWARD_LENGTH; - break; - } - if (int(current) - len < 0) { - pc = byteCode + Load32Aligned(pc + 4); - break; - } - if (CaseInsensitiveCompareStrings(chars + from, chars + int(current) - len, len * sizeof(CharT))) { - current -= len; - pc += BC_CHECK_NOT_BACK_REF_NO_CASE_BACKWARD_LENGTH; - } else { - pc = byteCode + Load32Aligned(pc + 4); - } - break; - - } - BYTECODE(CHECK_NOT_BACK_REF_NO_CASE_BACKWARD_UNICODE) { - int from = registers[insn >> BYTECODE_SHIFT]; - int len = registers[(insn >> BYTECODE_SHIFT) + 1] - from; - if (from < 0 || len <= 0) { - pc += BC_CHECK_NOT_BACK_REF_NO_CASE_BACKWARD_LENGTH; - break; - } - if (int(current) - len < 0) { - pc = byteCode + Load32Aligned(pc + 4); - break; - } - if (CaseInsensitiveCompareUCStrings(chars + from, chars + int(current) - len, len * sizeof(CharT))) { - current -= len; - pc += BC_CHECK_NOT_BACK_REF_NO_CASE_BACKWARD_LENGTH; - } else { - pc = byteCode + Load32Aligned(pc + 4); - } - break; - - } BYTECODE(CHECK_AT_START) if (current == 0) pc = byteCode + Load32Aligned(pc + 4); @@ -536,7 +472,7 @@ irregexp::InterpretCode(JSContext* cx, const uint8_t* byteCode, const CharT* cha pc += BC_CHECK_AT_START_LENGTH; break; BYTECODE(CHECK_NOT_AT_START) - if (current + (insn >> BYTECODE_SHIFT) == 0) + if (current == 0) pc += BC_CHECK_NOT_AT_START_LENGTH; else pc = byteCode + Load32Aligned(pc + 4); diff --git a/js/src/irregexp/RegExpMacroAssembler.cpp b/js/src/irregexp/RegExpMacroAssembler.cpp index 6b1ceba8a..d66d0d204 100644 --- a/js/src/irregexp/RegExpMacroAssembler.cpp +++ b/js/src/irregexp/RegExpMacroAssembler.cpp @@ -226,37 +226,32 @@ InterpretedRegExpMacroAssembler::CheckGreedyLoop(jit::Label* on_tos_equals_curre } void -InterpretedRegExpMacroAssembler::CheckNotAtStart(int cp_offset, jit::Label* on_not_at_start) +InterpretedRegExpMacroAssembler::CheckNotAtStart(jit::Label* on_not_at_start) { - Emit(BC_CHECK_NOT_AT_START, cp_offset); + Emit(BC_CHECK_NOT_AT_START, 0); EmitOrLink(on_not_at_start); } void -InterpretedRegExpMacroAssembler::CheckNotBackReference(int start_reg, bool read_backward, - jit::Label* on_no_match) +InterpretedRegExpMacroAssembler::CheckNotBackReference(int start_reg, jit::Label* on_no_match) { MOZ_ASSERT(start_reg >= 0); MOZ_ASSERT(start_reg <= kMaxRegister); - Emit(read_backward ? BC_CHECK_NOT_BACK_REF_BACKWARD : BC_CHECK_NOT_BACK_REF, - start_reg); + Emit(BC_CHECK_NOT_BACK_REF, start_reg); EmitOrLink(on_no_match); } void InterpretedRegExpMacroAssembler::CheckNotBackReferenceIgnoreCase(int start_reg, - bool read_backward, jit::Label* on_no_match, bool unicode) { MOZ_ASSERT(start_reg >= 0); MOZ_ASSERT(start_reg <= kMaxRegister); if (unicode) - Emit(read_backward ? BC_CHECK_NOT_BACK_REF_NO_CASE_BACKWARD_UNICODE : BC_CHECK_NOT_BACK_REF_NO_CASE_UNICODE, - start_reg); + Emit(BC_CHECK_NOT_BACK_REF_NO_CASE_UNICODE, start_reg); else - Emit(read_backward ? BC_CHECK_NOT_BACK_REF_NO_CASE_BACKWARD : BC_CHECK_NOT_BACK_REF_NO_CASE, - start_reg); + Emit(BC_CHECK_NOT_BACK_REF_NO_CASE, start_reg); EmitOrLink(on_no_match); } diff --git a/js/src/irregexp/RegExpMacroAssembler.h b/js/src/irregexp/RegExpMacroAssembler.h index c5def92f2..dca2edf90 100644 --- a/js/src/irregexp/RegExpMacroAssembler.h +++ b/js/src/irregexp/RegExpMacroAssembler.h @@ -110,10 +110,10 @@ class MOZ_STACK_CLASS RegExpMacroAssembler virtual void CheckCharacterGT(char16_t limit, jit::Label* on_greater) = 0; virtual void CheckCharacterLT(char16_t limit, jit::Label* on_less) = 0; virtual void CheckGreedyLoop(jit::Label* on_tos_equals_current_position) = 0; - virtual void CheckNotAtStart(int cp_offset, jit::Label* on_not_at_start) = 0; - virtual void CheckNotBackReference(int start_reg, bool read_backward, jit::Label* on_no_match) = 0; - virtual void CheckNotBackReferenceIgnoreCase(int start_reg, bool read_backward, - jit::Label* on_no_match, bool unicode) = 0; + virtual void CheckNotAtStart(jit::Label* on_not_at_start) = 0; + virtual void CheckNotBackReference(int start_reg, jit::Label* on_no_match) = 0; + virtual void CheckNotBackReferenceIgnoreCase(int start_reg, jit::Label* on_no_match, + bool unicode) = 0; // Check the current character for a match with a literal character. If we // fail to match then goto the on_failure label. End of input always @@ -245,10 +245,9 @@ class MOZ_STACK_CLASS InterpretedRegExpMacroAssembler final : public RegExpMacro void CheckCharacterGT(char16_t limit, jit::Label* on_greater); void CheckCharacterLT(char16_t limit, jit::Label* on_less); void CheckGreedyLoop(jit::Label* on_tos_equals_current_position); - void CheckNotAtStart(int cp_offset, jit::Label* on_not_at_start); - void CheckNotBackReference(int start_reg, bool read_backward, jit::Label* on_no_match); - void CheckNotBackReferenceIgnoreCase(int start_reg, bool read_backward, - jit::Label* on_no_match, bool unicode); + void CheckNotAtStart(jit::Label* on_not_at_start); + void CheckNotBackReference(int start_reg, jit::Label* on_no_match); + void CheckNotBackReferenceIgnoreCase(int start_reg, jit::Label* on_no_match, bool unicode); void CheckNotCharacter(unsigned c, jit::Label* on_not_equal); void CheckNotCharacterAfterAnd(unsigned c, unsigned and_with, jit::Label* on_not_equal); void CheckNotCharacterAfterMinusAnd(char16_t c, char16_t minus, char16_t and_with, diff --git a/js/src/irregexp/RegExpParser.cpp b/js/src/irregexp/RegExpParser.cpp index 1ad044e8e..d4308d0d8 100644 --- a/js/src/irregexp/RegExpParser.cpp +++ b/js/src/irregexp/RegExpParser.cpp @@ -227,7 +227,6 @@ RegExpParser::RegExpParser(frontend::TokenStream& ts, LifoAlloc* alloc, alloc(alloc), captures_(nullptr), next_pos_(chars), - captures_started_(0), end_(end), current_(kEndMarker), capture_count_(0), @@ -420,8 +419,7 @@ RangeAtom(LifoAlloc* alloc, char16_t from, char16_t to) static inline RegExpTree* NegativeLookahead(LifoAlloc* alloc, char16_t from, char16_t to) { - return alloc->newInfallible(RangeAtom(alloc, from, to), false, - 0, 0, RegExpLookaround::LOOKAHEAD); + return alloc->newInfallible(RangeAtom(alloc, from, to), false, 0, 0); } static bool @@ -1216,38 +1214,6 @@ RegExpParser::ParseBackReferenceIndex(int* index_out) return true; } -template -RegExpCapture* -RegExpParser::GetCapture(int index) { - // The index for the capture groups are one-based. Its index in the list is - // zero-based. - int known_captures = - is_scanned_for_captures_ ? capture_count_ : captures_started_; - MOZ_ASSERT(index <= known_captures); - if (captures_ == NULL) { - captures_ = alloc->newInfallible(*alloc); - } - while ((int)captures_->length() < known_captures) { - RegExpCapture* capture = alloc->newInfallible(nullptr, captures_->length() + 1); - captures_->append(capture); - } - return (*captures_)[index - 1]; -} - - -template -bool -RegExpParser::RegExpParserState::IsInsideCaptureGroup(int index) { - for (RegExpParserState* s = this; s != NULL; s = s->previous_state()) { - if (s->group_type() != CAPTURE) continue; - // Return true if we found the matching capture index. - if (index == s->capture_index()) return true; - // Abort if index is larger than what has been parsed up till this state. - if (index > s->capture_index()) return false; - } - return false; -} - // QuantifierPrefix :: // { DecimalDigits } // { DecimalDigits , } @@ -1490,24 +1456,24 @@ RegExpTree* RegExpParser::ParseDisjunction() { // Used to store current state while parsing subexpressions. - RegExpParserState initial_state(alloc, nullptr, INITIAL, RegExpLookaround::LOOKAHEAD, 0); - RegExpParserState* state = &initial_state; + RegExpParserState initial_state(alloc, nullptr, INITIAL, 0); + RegExpParserState* stored_state = &initial_state; // Cache the builder in a local variable for quick access. RegExpBuilder* builder = initial_state.builder(); while (true) { switch (current()) { case kEndMarker: - if (state->IsSubexpression()) { + if (stored_state->IsSubexpression()) { // Inside a parenthesized group when hitting end of input. return ReportError(JSMSG_MISSING_PAREN); } - MOZ_ASSERT(INITIAL == state->group_type()); + MOZ_ASSERT(INITIAL == stored_state->group_type()); // Parsing completed successfully. return builder->ToRegExp(); case ')': { - if (!state->IsSubexpression()) + if (!stored_state->IsSubexpression()) return ReportError(JSMSG_UNMATCHED_RIGHT_PAREN); - MOZ_ASSERT(INITIAL != state->group_type()); + MOZ_ASSERT(INITIAL != stored_state->group_type()); Advance(); // End disjunction parsing and convert builder content to new single @@ -1516,30 +1482,29 @@ RegExpParser::ParseDisjunction() int end_capture_index = captures_started(); - int capture_index = state->capture_index(); - SubexpressionType group_type = state->group_type(); + int capture_index = stored_state->capture_index(); + SubexpressionType group_type = stored_state->group_type(); + + // Restore previous state. + stored_state = stored_state->previous_state(); + builder = stored_state->builder(); // Build result of subexpression. if (group_type == CAPTURE) { - RegExpCapture* capture = GetCapture(capture_index); - capture->set_body(body); + RegExpCapture* capture = alloc->newInfallible(body, capture_index); + (*captures_)[capture_index - 1] = capture; body = capture; } else if (group_type != GROUPING) { - MOZ_ASSERT(group_type == POSITIVE_LOOKAROUND || - group_type == NEGATIVE_LOOKAROUND); - bool is_positive = (group_type == POSITIVE_LOOKAROUND); - body = alloc->newInfallible(body, + MOZ_ASSERT(group_type == POSITIVE_LOOKAHEAD || + group_type == NEGATIVE_LOOKAHEAD); + bool is_positive = (group_type == POSITIVE_LOOKAHEAD); + body = alloc->newInfallible(body, is_positive, end_capture_index - capture_index, - capture_index, - state->lookaround_type()); + capture_index); } - - // Restore previous state. - state = state->previous_state(); - builder = state->builder(); builder->AddAtom(body); - if (unicode_ && (group_type == POSITIVE_LOOKAROUND || group_type == NEGATIVE_LOOKAROUND)) + if (unicode_ && (group_type == POSITIVE_LOOKAHEAD || group_type == NEGATIVE_LOOKAHEAD)) continue; // For compatability with JSC and ES3, we allow quantifiers after // lookaheads, and break in all cases. @@ -1599,7 +1564,6 @@ RegExpParser::ParseDisjunction() } case '(': { SubexpressionType subexpr_type = CAPTURE; - RegExpLookaround::Type lookaround_type = state->lookaround_type(); Advance(); if (current() == '?') { switch (Next()) { @@ -1607,39 +1571,26 @@ RegExpParser::ParseDisjunction() subexpr_type = GROUPING; break; case '=': - lookaround_type = RegExpLookaround::LOOKAHEAD; - subexpr_type = POSITIVE_LOOKAROUND; + subexpr_type = POSITIVE_LOOKAHEAD; break; case '!': - lookaround_type = RegExpLookaround::LOOKAHEAD; - subexpr_type = NEGATIVE_LOOKAROUND; + subexpr_type = NEGATIVE_LOOKAHEAD; break; - case '<': - Advance(); - lookaround_type = RegExpLookaround::LOOKBEHIND; - if (Next() == '=') { - subexpr_type = POSITIVE_LOOKAROUND; - break; - } else if (Next() == '!') { - subexpr_type = NEGATIVE_LOOKAROUND; - break; - } - // We didn't get a positive or negative after '<'. - // That's an error. - return ReportError(JSMSG_INVALID_GROUP); default: return ReportError(JSMSG_INVALID_GROUP); } Advance(2); } else { + if (captures_ == nullptr) + captures_ = alloc->newInfallible(*alloc); if (captures_started() >= kMaxCaptures) return ReportError(JSMSG_TOO_MANY_PARENS); - captures_started_++; + captures_->append((RegExpCapture*) nullptr); } // Store current state and begin new disjunction parsing. - state = alloc->newInfallible(alloc, state, subexpr_type, - lookaround_type, captures_started_); - builder = state->builder(); + stored_state = alloc->newInfallible(alloc, stored_state, subexpr_type, + captures_started()); + builder = stored_state->builder(); continue; } case '[': { @@ -1694,18 +1645,19 @@ RegExpParser::ParseDisjunction() case '7': case '8': case '9': { int index = 0; if (ParseBackReferenceIndex(&index)) { - if (state->IsInsideCaptureGroup(index)) { - // The backreference is inside the capture group it refers to. - // Nothing can possibly have been captured yet. - builder->AddEmpty(); - } else { - RegExpCapture* capture = GetCapture(index); - RegExpTree* atom = alloc->newInfallible(capture); - if (unicode_) - builder->AddAtom(UnicodeBackReferenceAtom(alloc, atom)); - else - builder->AddAtom(atom); + RegExpCapture* capture = nullptr; + if (captures_ != nullptr && index <= (int) captures_->length()) { + capture = (*captures_)[index - 1]; + } + if (capture == nullptr) { + builder->AddEmpty(); + break; } + RegExpTree* atom = alloc->newInfallible(capture); + if (unicode_) + builder->AddAtom(UnicodeBackReferenceAtom(alloc, atom)); + else + builder->AddAtom(atom); break; } if (unicode_) diff --git a/js/src/irregexp/RegExpParser.h b/js/src/irregexp/RegExpParser.h index ee57f0436..a58800a91 100644 --- a/js/src/irregexp/RegExpParser.h +++ b/js/src/irregexp/RegExpParser.h @@ -229,7 +229,7 @@ class RegExpParser bool simple() { return simple_; } bool contains_anchor() { return contains_anchor_; } void set_contains_anchor() { contains_anchor_ = true; } - int captures_started() { return captures_started_; } + int captures_started() { return captures_ == nullptr ? 0 : captures_->length(); } const CharT* position() { return next_pos_ - 1; } static const int kMaxCaptures = 1 << 16; @@ -239,8 +239,8 @@ class RegExpParser enum SubexpressionType { INITIAL, CAPTURE, // All positive values represent captures. - POSITIVE_LOOKAROUND, - NEGATIVE_LOOKAROUND, + POSITIVE_LOOKAHEAD, + NEGATIVE_LOOKAHEAD, GROUPING }; @@ -249,12 +249,10 @@ class RegExpParser RegExpParserState(LifoAlloc* alloc, RegExpParserState* previous_state, SubexpressionType group_type, - RegExpLookaround::Type lookaround_type, int disjunction_capture_index) : previous_state_(previous_state), builder_(alloc->newInfallible(alloc)), group_type_(group_type), - lookaround_type_(lookaround_type), disjunction_capture_index_(disjunction_capture_index) {} // Parser state of containing expression, if any. @@ -264,16 +262,11 @@ class RegExpParser RegExpBuilder* builder() { return builder_; } // Type of regexp being parsed (parenthesized group or entire regexp). SubexpressionType group_type() { return group_type_; } - // Lookahead or Lookbehind. - RegExpLookaround::Type lookaround_type() { return lookaround_type_; } // Index in captures array of first capture in this sub-expression, if any. // Also the capture index of this sub-expression itself, if group_type // is CAPTURE. int capture_index() { return disjunction_capture_index_; } - // Check whether the parser is inside a capture group with the given index. - bool IsInsideCaptureGroup(int index); - private: // Linked list implementation of stack of states. RegExpParserState* previous_state_; @@ -281,15 +274,10 @@ class RegExpParser RegExpBuilder* builder_; // Stored disjunction type (capture, look-ahead or grouping), if any. SubexpressionType group_type_; - // Stored read direction. - RegExpLookaround::Type lookaround_type_; // Stored disjunction's capture index (if any). int disjunction_capture_index_; }; - // Return the 1-indexed RegExpCapture object, allocate if necessary. - RegExpCapture* GetCapture(int index); - widechar current() { return current_; } bool has_more() { return has_more_; } bool has_next() { return next_pos_ < end_; } @@ -306,7 +294,6 @@ class RegExpParser const CharT* next_pos_; const CharT* end_; widechar current_; - int captures_started_; // The capture count is only valid after we have scanned for captures. int capture_count_; bool has_more_; -- cgit v1.2.3 From 722161775b9ec9314d1b02f567e42b83115cf993 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Mon, 20 Jan 2020 11:59:36 +0100 Subject: Issue #1338 - Bump NSS version Our NSS version is closer to the currently-released .1, so bump version to that. Note: we still have some additional patches to the in-tree version in place so this isn't a 100% match to the RTM one. --- security/nss/lib/nss/nss.h | 2 +- security/nss/lib/softoken/softkver.h | 2 +- security/nss/lib/util/nssutil.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/security/nss/lib/nss/nss.h b/security/nss/lib/nss/nss.h index e56ce2f59..b8d9da65c 100644 --- a/security/nss/lib/nss/nss.h +++ b/security/nss/lib/nss/nss.h @@ -25,7 +25,7 @@ #define NSS_VERSION "3.48" _NSS_CUSTOMIZED #define NSS_VMAJOR 3 #define NSS_VMINOR 48 -#define NSS_VPATCH 0 +#define NSS_VPATCH 1 #define NSS_VBUILD 0 #define NSS_BETA PR_FALSE diff --git a/security/nss/lib/softoken/softkver.h b/security/nss/lib/softoken/softkver.h index fce11cd6d..7238d257f 100644 --- a/security/nss/lib/softoken/softkver.h +++ b/security/nss/lib/softoken/softkver.h @@ -20,7 +20,7 @@ #define SOFTOKEN_VERSION "3.48" SOFTOKEN_ECC_STRING #define SOFTOKEN_VMAJOR 3 #define SOFTOKEN_VMINOR 48 -#define SOFTOKEN_VPATCH 0 +#define SOFTOKEN_VPATCH 1 #define SOFTOKEN_VBUILD 0 #define SOFTOKEN_BETA PR_FALSE diff --git a/security/nss/lib/util/nssutil.h b/security/nss/lib/util/nssutil.h index bbfec5000..4a4dd7a53 100644 --- a/security/nss/lib/util/nssutil.h +++ b/security/nss/lib/util/nssutil.h @@ -22,7 +22,7 @@ #define NSSUTIL_VERSION "3.48" #define NSSUTIL_VMAJOR 3 #define NSSUTIL_VMINOR 48 -#define NSSUTIL_VPATCH 0 +#define NSSUTIL_VPATCH 1 #define NSSUTIL_VBUILD 0 #define NSSUTIL_BETA PR_FALSE -- cgit v1.2.3 From c6dbf554496191a0cfe4c8f5dbe8c96031d1445b Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Mon, 20 Jan 2020 22:35:36 +0100 Subject: Issue #1354 - Clear the current context when MakeCurrent() fails. --- dom/canvas/WebGLContextValidate.cpp | 7 ++++++ gfx/gl/GLContext.cpp | 13 +++++----- gfx/gl/GLContext.h | 6 ++--- gfx/gl/GLContextCGL.h | 2 +- gfx/gl/GLContextGLX.h | 1 + gfx/gl/GLContextProviderCGL.mm | 22 ++++++----------- gfx/gl/GLContextProviderEAGL.mm | 41 ++++++++++++-------------------- gfx/gl/GLContextProviderEGL.cpp | 47 +++++++++++++++++++------------------ gfx/gl/GLContextProviderGLX.cpp | 24 +++++++++---------- gfx/gl/GLContextProviderWGL.cpp | 13 ++++------ 10 files changed, 81 insertions(+), 95 deletions(-) diff --git a/dom/canvas/WebGLContextValidate.cpp b/dom/canvas/WebGLContextValidate.cpp index ebf0aa8c2..30d4c6522 100644 --- a/dom/canvas/WebGLContextValidate.cpp +++ b/dom/canvas/WebGLContextValidate.cpp @@ -440,6 +440,13 @@ WebGLContext::InitAndValidateGL(FailureReason* const out_failReason) { MOZ_RELEASE_ASSERT(gl, "GFX: GL not initialized"); + if (!gl->MakeCurrent(true)) { + MOZ_ASSERT(false); + *out_failReason = { "FEATURE_FAILURE_WEBGL_MAKECURRENT", + "Failed to MakeCurrent for init." }; + return false; + } + // Unconditionally create a new format usage authority. This is // important when restoring contexts and extensions need to add // formats back into the authority. diff --git a/gfx/gl/GLContext.cpp b/gfx/gl/GLContext.cpp index 1515b8627..3fb87822d 100644 --- a/gfx/gl/GLContext.cpp +++ b/gfx/gl/GLContext.cpp @@ -578,6 +578,10 @@ GLContext::LoadFeatureSymbols(const char* prefix, bool trygl, const SymLoadStruc bool GLContext::InitWithPrefixImpl(const char* prefix, bool trygl) { + // wglGetProcAddress requires a current context. + if (!MakeCurrent(true)) + return false; + mWorkAroundDriverBugs = gfxPrefs::WorkAroundDriverBugs(); const SymLoadStruct coreSymbols[] = { @@ -714,7 +718,6 @@ GLContext::InitWithPrefixImpl(const char* prefix, bool trygl) //////////////// - MakeCurrent(); MOZ_ASSERT(mProfile != ContextProfile::Unknown); uint32_t version = 0; @@ -2253,13 +2256,11 @@ GLContext::MarkDestroyed() mBlitHelper = nullptr; mReadTexImageHelper = nullptr; - if (MakeCurrent()) { + mIsDestroyed = true; + mSymbols.Zero(); + if (MakeCurrent(true)) { mTexGarbageBin->GLContextTeardown(); - } else { - NS_WARNING("MakeCurrent() failed during MarkDestroyed! Skipping GL object teardown."); } - - mSymbols.Zero(); } #ifdef MOZ_GL_DEBUG diff --git a/gfx/gl/GLContext.h b/gfx/gl/GLContext.h index 6e3e22207..4c1f4f55c 100644 --- a/gfx/gl/GLContext.h +++ b/gfx/gl/GLContext.h @@ -353,6 +353,7 @@ public: protected: bool mIsOffscreen; bool mContextLost; + bool mIsDestroyed = false; /** * mVersion store the OpenGL's version, multiplied by 100. For example, if @@ -3265,7 +3266,7 @@ public: #endif return MakeCurrentImpl(aForce); } - + virtual bool Init() = 0; virtual bool SetupLookupFunction() = 0; @@ -3273,8 +3274,7 @@ public: virtual void ReleaseSurface() {} bool IsDestroyed() { - // MarkDestroyed will mark all these as null. - return mSymbols.fUseProgram == nullptr; + return mIsDestroyed; } GLContext* GetSharedContext() { return mSharedContext; } diff --git a/gfx/gl/GLContextCGL.h b/gfx/gl/GLContextCGL.h index 1a29f3d15..23616d861 100644 --- a/gfx/gl/GLContextCGL.h +++ b/gfx/gl/GLContextCGL.h @@ -24,7 +24,7 @@ class GLContextCGL : public GLContext { friend class GLContextProviderCGL; - NSOpenGLContext* mContext; + NSOpenGLContext* const mContext; public: MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(GLContextCGL, override) diff --git a/gfx/gl/GLContextGLX.h b/gfx/gl/GLContextGLX.h index 1f2cee08d..0463669e9 100644 --- a/gfx/gl/GLContextGLX.h +++ b/gfx/gl/GLContextGLX.h @@ -86,6 +86,7 @@ private: GLXContext mContext; Display* mDisplay; GLXDrawable mDrawable; + Maybe mOverrideDrawable; bool mDeleteDrawable; bool mDoubleBuffered; diff --git a/gfx/gl/GLContextProviderCGL.mm b/gfx/gl/GLContextProviderCGL.mm index ceab3046c..7cc89eac9 100644 --- a/gfx/gl/GLContextProviderCGL.mm +++ b/gfx/gl/GLContextProviderCGL.mm @@ -83,26 +83,13 @@ GLContextCGL::GLContextCGL(CreateContextFlags flags, const SurfaceCaps& caps, GLContextCGL::~GLContextCGL() { MarkDestroyed(); - - if (mContext) { - if ([NSOpenGLContext currentContext] == mContext) { - // Clear the current context before releasing. If we don't do - // this, the next time we call [NSOpenGLContext currentContext], - // "invalid context" will be printed to the console. - [NSOpenGLContext clearCurrentContext]; - } - [mContext release]; - } - + [mContext release]; } bool GLContextCGL::Init() { - if (!InitWithPrefix("gl", true)) - return false; - - return true; + return InitWithPrefix("gl", true); } CGLContextObj @@ -114,6 +101,11 @@ GLContextCGL::GetCGLContext() const bool GLContextCGL::MakeCurrentImpl(bool aForce) { + if (IsDestroyed()) { + [NSOpenGLContext clearCurrentContext]; + return false; + } + if (!aForce && [NSOpenGLContext currentContext] == mContext) { return true; } diff --git a/gfx/gl/GLContextProviderEAGL.mm b/gfx/gl/GLContextProviderEAGL.mm index 507616e2f..11c7cce77 100644 --- a/gfx/gl/GLContextProviderEAGL.mm +++ b/gfx/gl/GLContextProviderEAGL.mm @@ -36,35 +36,24 @@ GLContextEAGL::GLContextEAGL(CreateContextFlags flags, const SurfaceCaps& caps, GLContextEAGL::~GLContextEAGL() { - MakeCurrent(); - - if (mBackbufferFB) { - fDeleteFramebuffers(1, &mBackbufferFB); - } - - if (mBackbufferRB) { - fDeleteRenderbuffers(1, &mBackbufferRB); + if (MakeCurrent()) { + if (mBackbufferFB) { + fDeleteFramebuffers(1, &mBackbufferFB); + } + if (mBackbufferRB) { + fDeleteRenderbuffers(1, &mBackbufferRB); + } } + mLayer = nil; MarkDestroyed(); - - if (mLayer) { - mLayer = nil; - } - - if (mContext) { - [EAGLContext setCurrentContext:nil]; - [mContext release]; - } + [mContext release]; } bool GLContextEAGL::Init() { - if (!InitWithPrefix("gl", true)) - return false; - - return true; + return InitWithPrefix("gl", true); } bool @@ -120,12 +109,12 @@ GLContextEAGL::MakeCurrentImpl(bool aForce) return true; } - if (mContext) { - if(![EAGLContext setCurrentContext:mContext]) { - return false; - } + if (IsDestroyed()) { + [EAGLContext setCurrentContext:nil]; + return false; } - return true; + + return [EAGLContext setCurrentContext:mContext]; } bool diff --git a/gfx/gl/GLContextProviderEGL.cpp b/gfx/gl/GLContextProviderEGL.cpp index 7979f3bf0..23fc3472d 100644 --- a/gfx/gl/GLContextProviderEGL.cpp +++ b/gfx/gl/GLContextProviderEGL.cpp @@ -150,13 +150,12 @@ is_power_of_two(int v) } static void -DestroySurface(EGLSurface oldSurface) { - if (oldSurface != EGL_NO_SURFACE) { - sEGLLibrary.fMakeCurrent(EGL_DISPLAY(), - EGL_NO_SURFACE, EGL_NO_SURFACE, - EGL_NO_CONTEXT); - sEGLLibrary.fDestroySurface(EGL_DISPLAY(), oldSurface); +DestroySurface(const EGLSurface surf) { + if (!surf) { + // Nothing to do. + return; } + sEGLLibrary.fDestroySurface(EGL_DISPLAY(), surf); } static EGLSurface @@ -223,7 +222,7 @@ GLContextEGL::~GLContextEGL() sEGLLibrary.fDestroyContext(EGL_DISPLAY(), mContext); sEGLLibrary.UnsetCachedCurrentContext(); - mozilla::gl::DestroySurface(mSurface); + DestroySurface(mSurface); } bool @@ -247,12 +246,7 @@ GLContextEGL::Init() if (!InitWithPrefix("gl", true)) return false; - bool current = MakeCurrent(); - if (!current) { - gfx::LogFailure(NS_LITERAL_CSTRING( - "Couldn't get device attachments for device.")); - return false; - } + MOZ_ASSERT(IsCurrent()); static_assert(sizeof(GLint) >= sizeof(int32_t), "GLint is smaller than int32_t"); mMaxTextureImageSize = INT32_MAX; @@ -303,7 +297,10 @@ GLContextEGL::ReleaseTexImage() } void -GLContextEGL::SetEGLSurfaceOverride(EGLSurface surf) { +GLContextEGL::SetEGLSurfaceOverride(const EGLSurface surf) { + + MOZ_ASSERT(!surf || surf != mSurface); + if (Screen()) { /* Blit `draw` to `read` if we need to, before we potentially juggle * `read` around. If we don't, we might attach a different `read`, @@ -314,12 +311,17 @@ GLContextEGL::SetEGLSurfaceOverride(EGLSurface surf) { } mSurfaceOverride = surf; - DebugOnly ok = MakeCurrent(true); - MOZ_ASSERT(ok); + MOZ_ALWAYS_TRUE(MakeCurrent(true)); } bool GLContextEGL::MakeCurrentImpl(bool aForce) { + if (IsDestroyed()) { + //Clear and exit + sEGLLibrary.fMakeCurrent(EGL_DISPLAY(), nullptr, nullptr, nullptr); + return false; + } + bool succeeded = true; // Assume that EGL has the same problem as WGL does, @@ -373,7 +375,7 @@ GLContextEGL::IsCurrent() { } bool -GLContextEGL::RenewSurface(nsIWidget* aWidget) { +GLContextEGL::RenewSurface(nsIWidget* const aWidget) { if (!mOwnsContext) { return false; } @@ -389,13 +391,12 @@ GLContextEGL::RenewSurface(nsIWidget* aWidget) { void GLContextEGL::ReleaseSurface() { - if (mOwnsContext) { - mozilla::gl::DestroySurface(mSurface); - } - if (mSurface == mSurfaceOverride) { - mSurfaceOverride = EGL_NO_SURFACE; + if (!mOwnsContext) { + return; } - mSurface = EGL_NO_SURFACE; + + DestroySurface(mSurface); + mSurface = nullptr; } bool diff --git a/gfx/gl/GLContextProviderGLX.cpp b/gfx/gl/GLContextProviderGLX.cpp index 539520a8c..178052f8c 100644 --- a/gfx/gl/GLContextProviderGLX.cpp +++ b/gfx/gl/GLContextProviderGLX.cpp @@ -894,20 +894,12 @@ GLContextGLX::~GLContextGLX() return; } - // see bug 659842 comment 76 -#ifdef DEBUG - bool success = -#endif - mGLX->xMakeCurrent(mDisplay, X11None, nullptr); - MOZ_ASSERT(success, - "glXMakeCurrent failed to release GL context before we call " - "glXDestroyContext!"); - mGLX->xDestroyContext(mDisplay, mContext); if (mDeleteDrawable) { mGLX->xDestroyPixmap(mDisplay, mDrawable); } + MOZ_ASSERT(!mOverrideDrawable); } @@ -944,6 +936,10 @@ GLContextGLX::MakeCurrentImpl(bool aForce) // DRI2InvalidateBuffers event before drawing. See bug 1280653. Unused << XPending(mDisplay); } + if (IsDestroyed()) { + MOZ_ALWAYS_TRUE(mGLX->xMakeCurrent(mDisplay, X11None, nullptr); + return false; // We did not MakeCurrent mContext, but that's what we wanted! + } succeeded = mGLX->xMakeCurrent(mDisplay, mDrawable, mContext); NS_ASSERTION(succeeded, "Failed to make GL context current!"); @@ -1017,16 +1013,18 @@ GLContextGLX::GetWSIInfo(nsCString* const out) const bool GLContextGLX::OverrideDrawable(GLXDrawable drawable) { - if (Screen()) + if (Screen()) { Screen()->AssureBlitted(); - Bool result = mGLX->xMakeCurrent(mDisplay, drawable, mContext); - return result; + } + mOverrideDrawable = Some(drawable); + return MakeCurrent(true); } bool GLContextGLX::RestoreDrawable() { - return mGLX->xMakeCurrent(mDisplay, mDrawable, mContext); + mOverrideDrawable = Nothing(); + return MakeCurrent(true); } GLContextGLX::GLContextGLX( diff --git a/gfx/gl/GLContextProviderWGL.cpp b/gfx/gl/GLContextProviderWGL.cpp index 35957259d..da8c93d10 100644 --- a/gfx/gl/GLContextProviderWGL.cpp +++ b/gfx/gl/GLContextProviderWGL.cpp @@ -314,20 +314,17 @@ GLContextWGL::Init() if (!mDC || !mContext) return false; - // see bug 929506 comment 29. wglGetProcAddress requires a current context. - if (!sWGLLib.fMakeCurrent(mDC, mContext)) - return false; - SetupLookupFunction(); - if (!InitWithPrefix("gl", true)) - return false; - - return true; + return InitWithPrefix("gl", true); } bool GLContextWGL::MakeCurrentImpl(bool aForce) { + if (IsDestroyed()) { + MOZ_ALWAYS_TRUE(sWGLLib.fMakeCurrent(0, 0)); + } + BOOL succeeded = true; // wglGetCurrentContext seems to just pull the HGLRC out -- cgit v1.2.3 From fabe21d593bd09e50ffc9932b074305f15d5409a Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Tue, 21 Jan 2020 21:23:46 +0100 Subject: Issue #1354 - Fix typo --- gfx/gl/GLContextProviderGLX.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfx/gl/GLContextProviderGLX.cpp b/gfx/gl/GLContextProviderGLX.cpp index 178052f8c..c44b1a9f0 100644 --- a/gfx/gl/GLContextProviderGLX.cpp +++ b/gfx/gl/GLContextProviderGLX.cpp @@ -937,7 +937,7 @@ GLContextGLX::MakeCurrentImpl(bool aForce) Unused << XPending(mDisplay); } if (IsDestroyed()) { - MOZ_ALWAYS_TRUE(mGLX->xMakeCurrent(mDisplay, X11None, nullptr); + MOZ_ALWAYS_TRUE(mGLX->xMakeCurrent(mDisplay, X11None, nullptr)); return false; // We did not MakeCurrent mContext, but that's what we wanted! } -- cgit v1.2.3 From a9290ef91ec408fa7886b99cc59be40b413a0ce0 Mon Sep 17 00:00:00 2001 From: Gaming4JC Date: Tue, 21 Jan 2020 20:00:48 -0500 Subject: Issue #1366 - Completely remove showModalDialog --- docshell/base/nsDocShell.cpp | 17 +- dom/base/nsDeprecatedOperationList.h | 1 - dom/base/nsGlobalWindow.cpp | 333 +-------------------- dom/base/nsGlobalWindow.h | 61 +--- dom/base/nsPIDOMWindow.h | 10 - dom/base/nsSandboxFlags.h | 3 +- dom/base/test/mochitest.ini | 4 - dom/base/test/mutationobserver_dialog.html | 62 ---- dom/base/test/test_dialogArguments.html | 31 -- dom/base/test/test_mutationobservers.html | 22 -- dom/html/test/file_iframe_sandbox_c_if4.html | 11 +- dom/html/test/file_iframe_sandbox_j_if1.html | 30 -- dom/html/test/file_iframe_sandbox_j_if2.html | 28 -- dom/html/test/file_iframe_sandbox_j_if3.html | 27 -- dom/html/test/mochitest.ini | 10 +- dom/html/test/test_bug391777.html | 25 -- dom/html/test/test_iframe_sandbox_general.html | 2 +- dom/html/test/test_iframe_sandbox_modal.html | 122 -------- dom/locales/en-US/chrome/dom/dom.properties | 2 - .../recognition/test/test_nested_eventloop.html | 4 +- dom/tests/mochitest/bugs/file_bug291653.html | 28 -- dom/tests/mochitest/bugs/file_bug504862.html | 22 -- dom/tests/mochitest/bugs/mochitest.ini | 12 - dom/tests/mochitest/bugs/test_bug291653.html | 56 ---- dom/tests/mochitest/bugs/test_bug406375.html | 37 --- dom/tests/mochitest/bugs/test_bug414291.html | 6 - dom/tests/mochitest/bugs/test_bug437361.html | 72 ----- dom/tests/mochitest/bugs/test_bug479143.html | 44 --- dom/tests/mochitest/bugs/test_bug504862.html | 45 --- dom/tests/mochitest/bugs/test_bug61098.html | 22 -- dom/tests/mochitest/bugs/test_bug735237.html | 38 --- .../mochitest/general/file_showModalDialog.html | 35 --- dom/tests/mochitest/general/mochitest.ini | 3 - .../mochitest/general/test_showModalDialog.html | 60 ---- dom/webidl/Window.webidl | 14 - embedding/browser/nsIWebBrowserChrome.idl | 3 - .../components/windowwatcher/nsWindowWatcher.cpp | 24 +- modules/libpref/init/all.js | 1 - 38 files changed, 14 insertions(+), 1313 deletions(-) delete mode 100644 dom/base/test/mutationobserver_dialog.html delete mode 100644 dom/base/test/test_dialogArguments.html delete mode 100644 dom/html/test/file_iframe_sandbox_j_if1.html delete mode 100644 dom/html/test/file_iframe_sandbox_j_if2.html delete mode 100644 dom/html/test/file_iframe_sandbox_j_if3.html delete mode 100644 dom/html/test/test_bug391777.html delete mode 100644 dom/html/test/test_iframe_sandbox_modal.html delete mode 100644 dom/tests/mochitest/bugs/file_bug291653.html delete mode 100644 dom/tests/mochitest/bugs/file_bug504862.html delete mode 100644 dom/tests/mochitest/bugs/test_bug291653.html delete mode 100644 dom/tests/mochitest/bugs/test_bug406375.html delete mode 100644 dom/tests/mochitest/bugs/test_bug437361.html delete mode 100644 dom/tests/mochitest/bugs/test_bug479143.html delete mode 100644 dom/tests/mochitest/bugs/test_bug504862.html delete mode 100644 dom/tests/mochitest/bugs/test_bug735237.html delete mode 100644 dom/tests/mochitest/general/file_showModalDialog.html delete mode 100644 dom/tests/mochitest/general/test_showModalDialog.html diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index ebaf07bcd..6104ebfa7 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -13356,24 +13356,9 @@ nsDocShell::EnsureScriptEnvironment() uint32_t chromeFlags; browserChrome->GetChromeFlags(&chromeFlags); - bool isModalContentWindow = - (mItemType == typeContent) && - (chromeFlags & nsIWebBrowserChrome::CHROME_MODAL_CONTENT_WINDOW); - // There can be various other content docshells associated with the - // top-level window, like sidebars. Make sure that we only create an - // nsGlobalModalWindow for the primary content shell. - if (isModalContentWindow) { - nsCOMPtr primaryItem; - nsresult rv = - mTreeOwner->GetPrimaryContentShell(getter_AddRefs(primaryItem)); - NS_ENSURE_SUCCESS(rv, rv); - isModalContentWindow = (primaryItem == this); - } - // If our window is modal and we're not opened as chrome, make // this window a modal content window. - mScriptGlobal = - NS_NewScriptGlobalObject(mItemType == typeChrome, isModalContentWindow); + mScriptGlobal = NS_NewScriptGlobalObject(mItemType == typeChrome); MOZ_ASSERT(mScriptGlobal); mScriptGlobal->SetDocShell(this); diff --git a/dom/base/nsDeprecatedOperationList.h b/dom/base/nsDeprecatedOperationList.h index ea4b05289..96a6c3ac0 100644 --- a/dom/base/nsDeprecatedOperationList.h +++ b/dom/base/nsDeprecatedOperationList.h @@ -34,7 +34,6 @@ DEPRECATED_OPERATION(UseOfCaptureEvents) DEPRECATED_OPERATION(UseOfReleaseEvents) DEPRECATED_OPERATION(UseOfDOM3LoadMethod) DEPRECATED_OPERATION(ChromeUseOfDOM3LoadMethod) -DEPRECATED_OPERATION(ShowModalDialog) DEPRECATED_OPERATION(Window_Content) DEPRECATED_OPERATION(SyncXMLHttpRequest) DEPRECATED_OPERATION(DataContainerEvent) diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 47b46dda0..0587eb892 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -909,7 +909,6 @@ nsPIDOMWindow::nsPIDOMWindow(nsPIDOMWindowOuter *aOuterWindow) mMayHaveMouseEnterLeaveEventListener(false), mMayHavePointerEnterLeaveEventListener(false), mInnerObjectsFreed(false), - mIsModalContentWindow(false), mIsActive(false), mIsBackground(false), mMediaSuspend(Preferences::GetBool("media.block-autoplay-until-in-foreground", true) ? nsISuspendedTypes::SUSPENDED_BLOCK : nsISuspendedTypes::NONE_SUSPENDED), @@ -1957,7 +1956,6 @@ nsGlobalWindow::CleanUp() } mArguments = nullptr; - mDialogArguments = nullptr; CleanupCachedXBLHandlers(this); @@ -2195,7 +2193,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INTERNAL(nsGlobalWindow) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mControllers) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mArguments) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDialogArguments) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mReturnValue) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mNavigator) @@ -2274,7 +2271,6 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsGlobalWindow) NS_IMPL_CYCLE_COLLECTION_UNLINK(mControllers) NS_IMPL_CYCLE_COLLECTION_UNLINK(mArguments) - NS_IMPL_CYCLE_COLLECTION_UNLINK(mDialogArguments) NS_IMPL_CYCLE_COLLECTION_UNLINK(mReturnValue) NS_IMPL_CYCLE_COLLECTION_UNLINK(mNavigator) @@ -3019,8 +3015,6 @@ nsGlobalWindow::SetNewDocument(nsIDocument* aDocument, } else { if (thisChrome) { newInnerWindow = nsGlobalChromeWindow::Create(this); - } else if (mIsModalContentWindow) { - newInnerWindow = nsGlobalModalWindow::Create(this); } else { newInnerWindow = nsGlobalWindow::Create(this); } @@ -3871,31 +3865,16 @@ nsGlobalWindow::SetArguments(nsIArray *aArguments) MOZ_ASSERT(IsOuterWindow()); nsresult rv; - // Historically, we've used the same machinery to handle openDialog arguments - // (exposed via window.arguments) and showModalDialog arguments (exposed via - // window.dialogArguments), even though the former is XUL-only and uses an XPCOM - // array while the latter is web-exposed and uses an arbitrary JS value. - // Moreover, per-spec |dialogArguments| is a property of the browsing context - // (outer), whereas |arguments| lives on the inner. - // // We've now mostly separated them, but the difference is still opaque to // nsWindowWatcher (the caller of SetArguments in this little back-and-forth // embedding waltz we do here). // // So we need to demultiplex the two cases here. nsGlobalWindow *currentInner = GetCurrentInnerWindowInternal(); - if (mIsModalContentWindow) { - // nsWindowWatcher blindly converts the original nsISupports into an array - // of length 1. We need to recover it, and then cast it back to the concrete - // object we know it to be. - nsCOMPtr supports = do_QueryElementAt(aArguments, 0, &rv); - NS_ENSURE_SUCCESS(rv, rv); - mDialogArguments = static_cast(supports.get()); - } else { - mArguments = aArguments; - rv = currentInner->DefineArgumentsProperty(aArguments); - NS_ENSURE_SUCCESS(rv, rv); - } + + mArguments = aArguments; + rv = currentInner->DefineArgumentsProperty(aArguments); + NS_ENSURE_SUCCESS(rv, rv); return NS_OK; } @@ -3904,7 +3883,6 @@ nsresult nsGlobalWindow::DefineArgumentsProperty(nsIArray *aArguments) { MOZ_ASSERT(IsInnerWindow()); - MOZ_ASSERT(!mIsModalContentWindow); // Handled separately. nsIScriptContext *ctx = GetOuterWindowInternal()->mContext; NS_ENSURE_TRUE(aArguments && ctx, NS_ERROR_NOT_INITIALIZED); @@ -5040,21 +5018,6 @@ nsGlobalWindow::IsPrivilegedChromeWindow(JSContext* aCx, JSObject* aObj) nsContentUtils::ObjectPrincipal(aObj) == nsContentUtils::GetSystemPrincipal(); } -/* static */ bool -nsGlobalWindow::IsShowModalDialogEnabled(JSContext*, JSObject*) -{ - static bool sAddedPrefCache = false; - static bool sIsDisabled; - static const char sShowModalDialogPref[] = "dom.disable_window_showModalDialog"; - - if (!sAddedPrefCache) { - Preferences::AddBoolVarCache(&sIsDisabled, sShowModalDialogPref, false); - sAddedPrefCache = true; - } - - return !sIsDisabled && !XRE_IsContentProcess(); -} - nsIDOMOfflineResourceList* nsGlobalWindow::GetApplicationCache(ErrorResult& aError) { @@ -9741,126 +9704,6 @@ nsGlobalWindow::ConvertDialogOptions(const nsAString& aOptions, } } -already_AddRefed -nsGlobalWindow::ShowModalDialogOuter(const nsAString& aUrl, - nsIVariant* aArgument, - const nsAString& aOptions, - nsIPrincipal& aSubjectPrincipal, - ErrorResult& aError) -{ - MOZ_RELEASE_ASSERT(IsOuterWindow()); - - if (mDoc) { - mDoc->WarnOnceAbout(nsIDocument::eShowModalDialog); - } - - if (!IsShowModalDialogEnabled()) { - aError.Throw(NS_ERROR_NOT_AVAILABLE); - return nullptr; - } - - RefPtr argHolder = - new DialogValueHolder(&aSubjectPrincipal, aArgument); - - // Before bringing up the window/dialog, unsuppress painting and flush - // pending reflows. - EnsureReflowFlushAndPaint(); - - if (!AreDialogsEnabled()) { - // We probably want to keep throwing here; silently doing nothing is a bit - // weird given the typical use cases of showModalDialog(). - aError.Throw(NS_ERROR_NOT_AVAILABLE); - return nullptr; - } - - if (ShouldPromptToBlockDialogs() && !ConfirmDialogIfNeeded()) { - aError.Throw(NS_ERROR_NOT_AVAILABLE); - return nullptr; - } - - nsCOMPtr dlgWin; - nsAutoString options(NS_LITERAL_STRING("-moz-internal-modal=1,status=1")); - - ConvertDialogOptions(aOptions, options); - - options.AppendLiteral(",scrollbars=1,centerscreen=1,resizable=0"); - - EnterModalState(); - uint32_t oldMicroTaskLevel = nsContentUtils::MicroTaskLevel(); - nsContentUtils::SetMicroTaskLevel(0); - aError = OpenInternal(aUrl, EmptyString(), options, - false, // aDialog - true, // aContentModal - true, // aCalledNoScript - true, // aDoJSFixups - true, // aNavigate - nullptr, argHolder, // args - nullptr, // aLoadInfo - false, // aForceNoOpener - getter_AddRefs(dlgWin)); - nsContentUtils::SetMicroTaskLevel(oldMicroTaskLevel); - LeaveModalState(); - if (aError.Failed()) { - return nullptr; - } - - nsCOMPtr dialog = do_QueryInterface(dlgWin); - if (!dialog) { - return nullptr; - } - - nsCOMPtr retVal; - aError = dialog->GetReturnValue(getter_AddRefs(retVal)); - MOZ_ASSERT(!aError.Failed()); - - return retVal.forget(); -} - -already_AddRefed -nsGlobalWindow::ShowModalDialog(const nsAString& aUrl, nsIVariant* aArgument, - const nsAString& aOptions, - nsIPrincipal& aSubjectPrincipal, - ErrorResult& aError) -{ - FORWARD_TO_OUTER_OR_THROW(ShowModalDialogOuter, - (aUrl, aArgument, aOptions, aSubjectPrincipal, - aError), aError, nullptr); -} - -void -nsGlobalWindow::ShowModalDialog(JSContext* aCx, const nsAString& aUrl, - JS::Handle aArgument, - const nsAString& aOptions, - JS::MutableHandle aRetval, - nsIPrincipal& aSubjectPrincipal, - ErrorResult& aError) -{ - MOZ_ASSERT(IsInnerWindow()); - - nsCOMPtr args; - aError = nsContentUtils::XPConnect()->JSToVariant(aCx, - aArgument, - getter_AddRefs(args)); - if (aError.Failed()) { - return; - } - - nsCOMPtr retVal = - ShowModalDialog(aUrl, args, aOptions, aSubjectPrincipal, aError); - if (aError.Failed()) { - return; - } - - JS::Rooted result(aCx); - if (retVal) { - aError = nsContentUtils::XPConnect()->VariantToJS(aCx, - FastGetGlobalJSObject(), - retVal, aRetval); - } else { - aRetval.setNull(); - } -} - class ChildCommandDispatcher : public Runnable { public: @@ -14613,174 +14456,6 @@ nsGlobalChromeWindow::TakeOpenerForInitialContentBrowser(mozIDOMWindowProxy** aO return NS_OK; } -// nsGlobalModalWindow implementation - -// QueryInterface implementation for nsGlobalModalWindow -NS_INTERFACE_MAP_BEGIN(nsGlobalModalWindow) - NS_INTERFACE_MAP_ENTRY(nsIDOMModalContentWindow) -NS_INTERFACE_MAP_END_INHERITING(nsGlobalWindow) - -NS_IMPL_ADDREF_INHERITED(nsGlobalModalWindow, nsGlobalWindow) -NS_IMPL_RELEASE_INHERITED(nsGlobalModalWindow, nsGlobalWindow) - - -void -nsGlobalWindow::GetDialogArgumentsOuter(JSContext* aCx, - JS::MutableHandle aRetval, - nsIPrincipal& aSubjectPrincipal, - ErrorResult& aError) -{ - MOZ_RELEASE_ASSERT(IsOuterWindow()); - MOZ_ASSERT(IsModalContentWindow(), - "This should only be called on modal windows!"); - - if (!mDialogArguments) { - MOZ_ASSERT(mIsClosed, "This window should be closed!"); - aRetval.setUndefined(); - return; - } - - // This does an internal origin check, and returns undefined if the subject - // does not subsumes the origin of the arguments. - JS::Rooted wrapper(aCx, GetWrapper()); - JSAutoCompartment ac(aCx, wrapper); - mDialogArguments->Get(aCx, wrapper, &aSubjectPrincipal, aRetval, aError); -} - -void -nsGlobalWindow::GetDialogArguments(JSContext* aCx, - JS::MutableHandle aRetval, - nsIPrincipal& aSubjectPrincipal, - ErrorResult& aError) -{ - FORWARD_TO_OUTER_OR_THROW(GetDialogArgumentsOuter, - (aCx, aRetval, aSubjectPrincipal, aError), - aError, ); -} - -/* static */ already_AddRefed -nsGlobalModalWindow::Create(nsGlobalWindow *aOuterWindow) -{ - RefPtr window = new nsGlobalModalWindow(aOuterWindow); - window->InitWasOffline(); - return window.forget(); -} - -NS_IMETHODIMP -nsGlobalModalWindow::GetDialogArguments(nsIVariant **aArguments) -{ - FORWARD_TO_OUTER_MODAL_CONTENT_WINDOW(GetDialogArguments, (aArguments), - NS_ERROR_NOT_INITIALIZED); - - // This does an internal origin check, and returns undefined if the subject - // does not subsumes the origin of the arguments. - return mDialogArguments->Get(nsContentUtils::SubjectPrincipal(), aArguments); -} - -/* static */ already_AddRefed -nsGlobalWindow::Create(nsGlobalWindow *aOuterWindow) -{ - RefPtr window = new nsGlobalWindow(aOuterWindow); - window->InitWasOffline(); - return window.forget(); -} - -void -nsGlobalWindow::InitWasOffline() -{ - mWasOffline = NS_IsOffline(); -} - -void -nsGlobalWindow::GetReturnValueOuter(JSContext* aCx, - JS::MutableHandle aReturnValue, - nsIPrincipal& aSubjectPrincipal, - ErrorResult& aError) -{ - MOZ_RELEASE_ASSERT(IsOuterWindow()); - MOZ_ASSERT(IsModalContentWindow(), - "This should only be called on modal windows!"); - - if (mReturnValue) { - JS::Rooted wrapper(aCx, GetWrapper()); - JSAutoCompartment ac(aCx, wrapper); - mReturnValue->Get(aCx, wrapper, &aSubjectPrincipal, aReturnValue, aError); - } else { - aReturnValue.setUndefined(); - } -} - -void -nsGlobalWindow::GetReturnValue(JSContext* aCx, - JS::MutableHandle aReturnValue, - nsIPrincipal& aSubjectPrincipal, - ErrorResult& aError) -{ - FORWARD_TO_OUTER_OR_THROW(GetReturnValueOuter, - (aCx, aReturnValue, aSubjectPrincipal, aError), - aError, ); -} - -NS_IMETHODIMP -nsGlobalModalWindow::GetReturnValue(nsIVariant **aRetVal) -{ - FORWARD_TO_OUTER_MODAL_CONTENT_WINDOW(GetReturnValue, (aRetVal), NS_OK); - - if (!mReturnValue) { - nsCOMPtr variant = CreateVoidVariant(); - variant.forget(aRetVal); - return NS_OK; - } - return mReturnValue->Get(nsContentUtils::SubjectPrincipal(), aRetVal); -} - -void -nsGlobalWindow::SetReturnValueOuter(JSContext* aCx, - JS::Handle aReturnValue, - nsIPrincipal& aSubjectPrincipal, - ErrorResult& aError) -{ - MOZ_RELEASE_ASSERT(IsOuterWindow()); - MOZ_ASSERT(IsModalContentWindow(), - "This should only be called on modal windows!"); - - nsCOMPtr returnValue; - aError = - nsContentUtils::XPConnect()->JSToVariant(aCx, aReturnValue, - getter_AddRefs(returnValue)); - if (!aError.Failed()) { - mReturnValue = new DialogValueHolder(&aSubjectPrincipal, returnValue); - } -} - -void -nsGlobalWindow::SetReturnValue(JSContext* aCx, - JS::Handle aReturnValue, - nsIPrincipal& aSubjectPrincipal, - ErrorResult& aError) -{ - FORWARD_TO_OUTER_OR_THROW(SetReturnValueOuter, - (aCx, aReturnValue, aSubjectPrincipal, aError), - aError, ); -} - -NS_IMETHODIMP -nsGlobalModalWindow::SetReturnValue(nsIVariant *aRetVal) -{ - FORWARD_TO_OUTER_MODAL_CONTENT_WINDOW(SetReturnValue, (aRetVal), NS_OK); - - mReturnValue = new DialogValueHolder(nsContentUtils::SubjectPrincipal(), - aRetVal); - return NS_OK; -} - -/* static */ -bool -nsGlobalWindow::IsModalContentWindow(JSContext* aCx, JSObject* aGlobal) -{ - return xpc::WindowOrNull(aGlobal)->IsModalContentWindow(); -} - #if defined(MOZ_WIDGET_ANDROID) int16_t nsGlobalWindow::Orientation(CallerType aCallerType) const diff --git a/dom/base/nsGlobalWindow.h b/dom/base/nsGlobalWindow.h index 1f420895c..5cfd3f056 100644 --- a/dom/base/nsGlobalWindow.h +++ b/dom/base/nsGlobalWindow.h @@ -458,9 +458,6 @@ public: static bool IsPrivilegedChromeWindow(JSContext* /* unused */, JSObject* aObj); - static bool IsShowModalDialogEnabled(JSContext* /* unused */ = nullptr, - JSObject* /* unused */ = nullptr); - bool DoResolve(JSContext* aCx, JS::Handle aObj, JS::Handle aId, JS::MutableHandle aDesc); @@ -583,9 +580,6 @@ public: return mIsChrome; } - using nsPIDOMWindow::IsModalContentWindow; - static bool IsModalContentWindow(JSContext* aCx, JSObject* aGlobal); - // GetScrollFrame does not flush. Callers should do it themselves as needed, // depending on which info they actually want off the scrollable frame. nsIScrollableFrame *GetScrollFrame(); @@ -950,12 +944,6 @@ public: mozilla::ErrorResult& aRv); void PrintOuter(mozilla::ErrorResult& aError); void Print(mozilla::ErrorResult& aError); - void ShowModalDialog(JSContext* aCx, const nsAString& aUrl, - JS::Handle aArgument, - const nsAString& aOptions, - JS::MutableHandle aRetval, - nsIPrincipal& aSubjectPrincipal, - mozilla::ErrorResult& aError); void PostMessageMoz(JSContext* aCx, JS::Handle aMessage, const nsAString& aTargetOrigin, const mozilla::dom::Optional >& aTransfer, @@ -1227,12 +1215,6 @@ public: mozilla::dom::Element* aPanel, mozilla::ErrorResult& aError); - void GetDialogArgumentsOuter(JSContext* aCx, JS::MutableHandle aRetval, - nsIPrincipal& aSubjectPrincipal, - mozilla::ErrorResult& aError); - void GetDialogArguments(JSContext* aCx, JS::MutableHandle aRetval, - nsIPrincipal& aSubjectPrincipal, - mozilla::ErrorResult& aError); void GetReturnValueOuter(JSContext* aCx, JS::MutableHandle aReturnValue, nsIPrincipal& aSubjectPrincipal, mozilla::ErrorResult& aError); @@ -1681,18 +1663,6 @@ protected: nsIPrincipal& aSubjectPrincipal, mozilla::ErrorResult& aError); - already_AddRefed - ShowModalDialogOuter(const nsAString& aUrl, nsIVariant* aArgument, - const nsAString& aOptions, - nsIPrincipal& aSubjectPrincipal, - mozilla::ErrorResult& aError); - - already_AddRefed - ShowModalDialog(const nsAString& aUrl, nsIVariant* aArgument, - const nsAString& aOptions, - nsIPrincipal& aSubjectPrincipal, - mozilla::ErrorResult& aError); - // Ask the user if further dialogs should be blocked, if dialogs are currently // being abused. This is used in the cases where we have no modifiable UI to // show, in that case we show a separate dialog to ask this question. @@ -1832,9 +1802,6 @@ protected: // For |window.arguments|, via |openDialog|. nsCOMPtr mArguments; - // For |window.dialogArguments|, via |showModalDialog|. - RefPtr mDialogArguments; - // Only used in the outer. RefPtr mReturnValue; @@ -2067,40 +2034,14 @@ public: nsCOMPtr mOpenerForInitialContentBrowser; }; -/* - * nsGlobalModalWindow inherits from nsGlobalWindow. It is the global - * object created for a modal content windows only (i.e. not modal - * chrome dialogs). - */ -class nsGlobalModalWindow : public nsGlobalWindow, - public nsIDOMModalContentWindow -{ -public: - NS_DECL_ISUPPORTS_INHERITED - NS_DECL_NSIDOMMODALCONTENTWINDOW - - static already_AddRefed Create(nsGlobalWindow *aOuterWindow); - -protected: - explicit nsGlobalModalWindow(nsGlobalWindow *aOuterWindow) - : nsGlobalWindow(aOuterWindow) - { - mIsModalContentWindow = true; - } - - ~nsGlobalModalWindow() {} -}; - /* factory function */ inline already_AddRefed -NS_NewScriptGlobalObject(bool aIsChrome, bool aIsModalContentWindow) +NS_NewScriptGlobalObject(bool aIsChrome) { RefPtr global; if (aIsChrome) { global = nsGlobalChromeWindow::Create(nullptr); - } else if (aIsModalContentWindow) { - global = nsGlobalModalWindow::Create(nullptr); } else { global = nsGlobalWindow::Create(nullptr); } diff --git a/dom/base/nsPIDOMWindow.h b/dom/base/nsPIDOMWindow.h index 47affbb06..5c07bf4d4 100644 --- a/dom/base/nsPIDOMWindow.h +++ b/dom/base/nsPIDOMWindow.h @@ -303,11 +303,6 @@ public: virtual bool CanClose() = 0; virtual void ForceClose() = 0; - bool IsModalContentWindow() const - { - return mIsModalContentWindow; - } - /** * Call this to indicate that some node (this window, its document, * or content in that document) has a paint event listener. @@ -629,11 +624,6 @@ protected: // This member is only used by inner windows. bool mInnerObjectsFreed; - - // This variable is used on both inner and outer windows (and they - // should match). - bool mIsModalContentWindow; - // Tracks activation state that's used for :-moz-window-inactive. // Only used on outer windows. bool mIsActive; diff --git a/dom/base/nsSandboxFlags.h b/dom/base/nsSandboxFlags.h index d18527597..b8c9ac357 100644 --- a/dom/base/nsSandboxFlags.h +++ b/dom/base/nsSandboxFlags.h @@ -29,8 +29,7 @@ const unsigned long SANDBOXED_NAVIGATION = 0x1; /** * This flag prevents content from creating new auxiliary browsing contexts, - * e.g. using the target attribute, the window.open() method, or the - * showModalDialog() method. + * e.g. using the target attribute, or the window.open() method. */ const unsigned long SANDBOXED_AUXILIARY_NAVIGATION = 0x2; diff --git a/dom/base/test/mochitest.ini b/dom/base/test/mochitest.ini index b3b804ce4..3dfd666f8 100644 --- a/dom/base/test/mochitest.ini +++ b/dom/base/test/mochitest.ini @@ -196,7 +196,6 @@ support-files = formReset.html invalid_accesscontrol.resource invalid_accesscontrol.resource^headers^ - mutationobserver_dialog.html orientationcommon.js script-1_bug597345.sjs script-2_bug597345.js @@ -627,9 +626,6 @@ subsuite = clipboard skip-if = toolkit == 'android' #bug 904183 [test_createHTMLDocument.html] [test_declare_stylesheet_obsolete.html] -[test_dialogArguments.html] -tags = openwindow -skip-if = toolkit == 'android' || e10s # showmodaldialog [test_document.all_iteration.html] [test_document.all_unqualified.html] [test_document_constructor.html] diff --git a/dom/base/test/mutationobserver_dialog.html b/dom/base/test/mutationobserver_dialog.html deleted file mode 100644 index 2cc815309..000000000 --- a/dom/base/test/mutationobserver_dialog.html +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - - - diff --git a/dom/base/test/test_dialogArguments.html b/dom/base/test/test_dialogArguments.html deleted file mode 100644 index 70a091d00..000000000 --- a/dom/base/test/test_dialogArguments.html +++ /dev/null @@ -1,31 +0,0 @@ - - - - Test for Bug 1019761 - - - - - - - - - diff --git a/dom/base/test/test_mutationobservers.html b/dom/base/test/test_mutationobservers.html index bde07c79c..a6de89595 100644 --- a/dom/base/test/test_mutationobservers.html +++ b/dom/base/test/test_mutationobservers.html @@ -484,28 +484,6 @@ function testSyncXHR() { function testSyncXHR2() { ok(callbackHandled, "Should have called the mutation callback!"); - then(testModalDialog); -} - -function testModalDialog() { - var didHandleCallback = false; - div.innerHTML = "12"; - m = new M(function(records, observer) { - is(records[0].type, "childList", "Should have got childList"); - is(records[0].removedNodes.length, 2, "Should have got removedNodes"); - is(records[0].addedNodes.length, 1, "Should have got addedNodes"); - observer.disconnect(); - m = null; - didHandleCallback = true; - }); - m.observe(div, { childList: true }); - div.innerHTML = "foo"; - try { - window.showModalDialog("mutationobserver_dialog.html"); - ok(didHandleCallback, "Should have called the callback while showing modal dialog!"); - } catch(e) { - todo(false, "showModalDialog not implemented on this platform"); - } then(testTakeRecords); } diff --git a/dom/html/test/file_iframe_sandbox_c_if4.html b/dom/html/test/file_iframe_sandbox_c_if4.html index 53bf49559..828592d63 100644 --- a/dom/html/test/file_iframe_sandbox_c_if4.html +++ b/dom/html/test/file_iframe_sandbox_c_if4.html @@ -12,7 +12,7 @@ } function doStuff() { - // try to open a new window via target="_blank", target="BC341604", window.open(), and showModalDialog() + // try to open a new window via target="_blank", target="BC341604", and window.open() // the window we try to open closes itself once it opens sendMouseEvent({type:'click'}, 'target_blank'); sendMouseEvent({type:'click'}, 'target_BC341604'); @@ -25,15 +25,6 @@ } ok(threw, "window.open threw a JS exception and was not allowed"); - - threw = false; - try { - window.showModalDialog("about:blank"); - } catch(error) { - threw = true; - } - - ok(threw, "window.showModalDialog threw a JS exception and was not allowed"); } diff --git a/dom/html/test/file_iframe_sandbox_j_if1.html b/dom/html/test/file_iframe_sandbox_j_if1.html deleted file mode 100644 index 6d4347dfc..000000000 --- a/dom/html/test/file_iframe_sandbox_j_if1.html +++ /dev/null @@ -1,30 +0,0 @@ - - - - - Test for Bug 766282 - - - - - - - I am sandboxed with "allow-scripts allow-popups allow-same-origin allow-forms allow-top-navigation". - - diff --git a/dom/html/test/file_iframe_sandbox_j_if2.html b/dom/html/test/file_iframe_sandbox_j_if2.html deleted file mode 100644 index 9552307ee..000000000 --- a/dom/html/test/file_iframe_sandbox_j_if2.html +++ /dev/null @@ -1,28 +0,0 @@ - - - - - Test for Bug 766282 - - - - - - - I am sandboxed but with "allow-scripts allow-popups allow-same-origin". - After my initial load, "allow-same-origin" is removed and then I open file_iframe_sandbox_k_if9.html, - which attemps to call a function in my parent. - This should succeed since the new sandbox flags shouldn't have taken affect on me until I'm reloaded. - - diff --git a/dom/html/test/file_iframe_sandbox_j_if3.html b/dom/html/test/file_iframe_sandbox_j_if3.html deleted file mode 100644 index 07c5b66c1..000000000 --- a/dom/html/test/file_iframe_sandbox_j_if3.html +++ /dev/null @@ -1,27 +0,0 @@ - - - - - Tests for Bug 766282 - - - - - - I am sandboxed but with "allow-popups allow-scripts allow-same-origin" - - diff --git a/dom/html/test/mochitest.ini b/dom/html/test/mochitest.ini index 024de1cd9..4a50a9c3f 100644 --- a/dom/html/test/mochitest.ini +++ b/dom/html/test/mochitest.ini @@ -154,9 +154,6 @@ support-files = file_iframe_sandbox_form_pass.html file_iframe_sandbox_g_if1.html file_iframe_sandbox_h_if1.html - file_iframe_sandbox_j_if1.html - file_iframe_sandbox_j_if2.html - file_iframe_sandbox_j_if3.html file_iframe_sandbox_k_if1.html file_iframe_sandbox_k_if2.html file_iframe_sandbox_k_if3.html @@ -471,9 +468,6 @@ skip-if = toolkit == 'android' # just copy the conditions from the test above tags = openwindow [test_iframe_sandbox_inheritance.html] tags = openwindow -[test_iframe_sandbox_modal.html] -tags = openwindow -skip-if = toolkit == 'android' || e10s #modal tests fail on android [test_iframe_sandbox_navigation.html] tags = openwindow [test_iframe_sandbox_navigation2.html] @@ -540,8 +534,6 @@ skip-if = toolkit == 'android' #bug 811644 [test_bug369370.html] skip-if = toolkit == "android" || toolkit == "windows" # disabled on Windows because of bug 1234520 [test_bug380383.html] -[test_bug391777.html] -skip-if = toolkit == 'android' || e10s [test_bug402680.html] [test_bug403868.html] [test_bug403868.xhtml] @@ -607,4 +599,4 @@ skip-if = os == "android" # up/down arrow keys not supported on android [test_script_module.html] support-files = file_script_module.html - file_script_nomodule.html \ No newline at end of file + file_script_nomodule.html diff --git a/dom/html/test/test_bug391777.html b/dom/html/test/test_bug391777.html deleted file mode 100644 index aa01a45de..000000000 --- a/dom/html/test/test_bug391777.html +++ /dev/null @@ -1,25 +0,0 @@ - - - - - Test for Bug 391777 - - - - -Mozilla Bug 391777 -

- - - diff --git a/dom/html/test/test_iframe_sandbox_general.html b/dom/html/test/test_iframe_sandbox_general.html index 6d3a190ee..83f0e9045 100644 --- a/dom/html/test/test_iframe_sandbox_general.html +++ b/dom/html/test/test_iframe_sandbox_general.html @@ -41,7 +41,7 @@ function ok_wrapper(result, desc) { passedTests++; } - if (completedTests == 33) { + if (completedTests == 32) { is(passedTests, completedTests, "There are " + completedTests + " general tests that should pass"); SimpleTest.finish(); } diff --git a/dom/html/test/test_iframe_sandbox_modal.html b/dom/html/test/test_iframe_sandbox_modal.html deleted file mode 100644 index 1307ea9a5..000000000 --- a/dom/html/test/test_iframe_sandbox_modal.html +++ /dev/null @@ -1,122 +0,0 @@ - - - - - - Tests for Bug 766282 - - - - - - - -Mozilla Bug 766282 - implement allow-popups directive for iframe sandbox -

-
- - - -
diff --git a/dom/locales/en-US/chrome/dom/dom.properties b/dom/locales/en-US/chrome/dom/dom.properties index 0472979d7..6bd3aac94 100644 --- a/dom/locales/en-US/chrome/dom/dom.properties +++ b/dom/locales/en-US/chrome/dom/dom.properties @@ -174,8 +174,6 @@ UseOfCaptureEventsWarning=Use of captureEvents() is deprecated. To upgrade your UseOfReleaseEventsWarning=Use of releaseEvents() is deprecated. To upgrade your code, use the DOM 2 removeEventListener() method. For more help http://developer.mozilla.org/en/docs/DOM:element.removeEventListener # LOCALIZATION NOTE: Do not translate "document.load()" or "XMLHttpRequest" UseOfDOM3LoadMethodWarning=Use of document.load() is deprecated. To upgrade your code, use the DOM XMLHttpRequest object. For more help https://developer.mozilla.org/en/XMLHttpRequest -# LOCALIZATION NOTE: Do not translate "window.showModalDialog()" or "window.open()" -ShowModalDialogWarning=Use of window.showModalDialog() is deprecated. Use window.open() instead. For more help https://developer.mozilla.org/en-US/docs/Web/API/Window.open # LOCALIZATION NOTE: Do not translate "window._content" or "window.content" Window_ContentWarning=window._content is deprecated. Please use window.content instead. # LOCALIZATION NOTE: Do not translate "XMLHttpRequest" diff --git a/dom/media/webspeech/recognition/test/test_nested_eventloop.html b/dom/media/webspeech/recognition/test/test_nested_eventloop.html index bdbed6524..8b4cea6d7 100644 --- a/dom/media/webspeech/recognition/test/test_nested_eventloop.html +++ b/dom/media/webspeech/recognition/test/test_nested_eventloop.html @@ -21,7 +21,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=650295 SimpleTest.waitForExplicitFinish(); /* - * window.showModalDialog() can be used to spin the event loop, causing + * SpecialPowers.spinEventLoop can be used to spin the event loop, causing * queued SpeechEvents (such as those created by calls to start(), stop() * or abort()) to be processed immediately. * When this is done from inside DOM event handlers, it is possible to @@ -33,7 +33,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=650295 } function doneFunc() { // Trigger gc now and wait some time to make sure this test gets the blame - // for any assertions caused by showModalDialog + // for any assertions caused by spinning the event loop. // // NB - The assertions should be gone, but this looks too scary to touch // during batch cleanup. diff --git a/dom/tests/mochitest/bugs/file_bug291653.html b/dom/tests/mochitest/bugs/file_bug291653.html deleted file mode 100644 index 4bfc8337e..000000000 --- a/dom/tests/mochitest/bugs/file_bug291653.html +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - Test for bug 291653 - - diff --git a/dom/tests/mochitest/bugs/file_bug504862.html b/dom/tests/mochitest/bugs/file_bug504862.html deleted file mode 100644 index dc11ced6f..000000000 --- a/dom/tests/mochitest/bugs/file_bug504862.html +++ /dev/null @@ -1,22 +0,0 @@ - - - diff --git a/dom/tests/mochitest/bugs/mochitest.ini b/dom/tests/mochitest/bugs/mochitest.ini index 309aab6e0..3743c6782 100644 --- a/dom/tests/mochitest/bugs/mochitest.ini +++ b/dom/tests/mochitest/bugs/mochitest.ini @@ -10,9 +10,6 @@ support-files = child_bug260264.html devicemotion_inner.html devicemotion_outer.html - file_bug291653.html - file_bug406375.html - file_bug504862.html file_bug593174_1.html file_bug593174_2.html file_bug809290_b1.html @@ -45,7 +42,6 @@ skip-if = toolkit == 'android' [test_bug260264_nested.html] [test_bug265203.html] [test_bug291377.html] -[test_bug291653.html] skip-if = toolkit == 'android' #TIMED_OUT [test_bug304459.html] [test_bug308856.html] @@ -67,28 +63,21 @@ skip-if = toolkit == 'android' #TIMED_OUT [test_bug396843.html] [test_bug400204.html] [test_bug404748.html] -[test_bug406375.html] -skip-if = toolkit == 'android' -[test_bug414291.html] -tags = openwindow [test_bug427744.html] skip-if = toolkit == 'android' [test_bug42976.html] [test_bug430276.html] -[test_bug437361.html] skip-if = toolkit == 'android' [test_bug440572.html] [test_bug456151.html] [test_bug458091.html] [test_bug459848.html] [test_bug465263.html] -[test_bug479143.html] skip-if = toolkit == 'android' [test_bug484775.html] [test_bug492925.html] [test_bug49312.html] [test_bug495219.html] -[test_bug504862.html] skip-if = toolkit == 'android' #RANDOM [test_bug529328.html] [test_bug531176.html] @@ -126,7 +115,6 @@ skip-if = toolkit == 'android' [test_bug698061.html] [test_bug698551.html] [test_bug707749.html] -[test_bug735237.html] [test_bug739038.html] [test_bug740811.html] [test_bug743615.html] diff --git a/dom/tests/mochitest/bugs/test_bug291653.html b/dom/tests/mochitest/bugs/test_bug291653.html deleted file mode 100644 index 1543cdd96..000000000 --- a/dom/tests/mochitest/bugs/test_bug291653.html +++ /dev/null @@ -1,56 +0,0 @@ - - - - - Test for Bug 291653 - - - - -Mozilla Bug 291653 -

- -
-
-
- - diff --git a/dom/tests/mochitest/bugs/test_bug406375.html b/dom/tests/mochitest/bugs/test_bug406375.html deleted file mode 100644 index 2cd459ffa..000000000 --- a/dom/tests/mochitest/bugs/test_bug406375.html +++ /dev/null @@ -1,37 +0,0 @@ - - - - - Test for Bug 406375 - - - - -Mozilla Bug 406375 -

- -
-
-
- - diff --git a/dom/tests/mochitest/bugs/test_bug414291.html b/dom/tests/mochitest/bugs/test_bug414291.html index 883e52bb4..0ee5cb393 100644 --- a/dom/tests/mochitest/bugs/test_bug414291.html +++ b/dom/tests/mochitest/bugs/test_bug414291.html @@ -16,7 +16,6 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=414291 var result1 = 0; var result2 = 0; -var result3 = 0; window.open("data:text/html,", "w1"); is(result1, 0, "window should not be opened either as modal or loaded synchronously."); @@ -24,11 +23,6 @@ is(result1, 0, "window should not be opened either as modal or loaded synchronou window.open("data:text/html,", "w2", "modal=yes"); is(result2, 0, "window should not be opened either as modal or data loaded synchronously."); -if (window.showModalDialog) { - result3 = window.showModalDialog("data:text/html,"); - is(result3, 3, "window should be opened as modal."); -} - diff --git a/dom/tests/mochitest/bugs/test_bug437361.html b/dom/tests/mochitest/bugs/test_bug437361.html deleted file mode 100644 index ecc2cb08d..000000000 --- a/dom/tests/mochitest/bugs/test_bug437361.html +++ /dev/null @@ -1,72 +0,0 @@ - - - - - Test for Bug 437361 - - - - - - -Mozilla Bug 437361 -

- -
-
- - - diff --git a/dom/tests/mochitest/bugs/test_bug479143.html b/dom/tests/mochitest/bugs/test_bug479143.html deleted file mode 100644 index 03db4ddea..000000000 --- a/dom/tests/mochitest/bugs/test_bug479143.html +++ /dev/null @@ -1,44 +0,0 @@ - - - - - Test for Bug 411103 - - - - -Mozilla Bug 479143 -

- - -
-
-
- - diff --git a/dom/tests/mochitest/bugs/test_bug504862.html b/dom/tests/mochitest/bugs/test_bug504862.html deleted file mode 100644 index 713165bc3..000000000 --- a/dom/tests/mochitest/bugs/test_bug504862.html +++ /dev/null @@ -1,45 +0,0 @@ - - - - - Test for Bug 504862 - - - - -Mozilla Bug 504862 - - - - diff --git a/dom/tests/mochitest/bugs/test_bug61098.html b/dom/tests/mochitest/bugs/test_bug61098.html index 4c6ce967d..ed16e099b 100644 --- a/dom/tests/mochitest/bugs/test_bug61098.html +++ b/dom/tests/mochitest/bugs/test_bug61098.html @@ -306,28 +306,6 @@ function runtestsInner() w.close(); - // Test that showModalDialog() works normally and then gets blocked - // on the second call. - if (window.showModalDialog) { - w = window.open(); - w.showModalDialog("data:text/html,%3Cscript>window.close();%3C/script>") - is (promptState, void(0), "Wrong prompt state"); - - try { - w.showModalDialog("data:text/html,%3Cscript>window.close();%3C/script>") - ok(false, "showModalDialog call should throw an exception"); - } catch(e) { - is(e.name, "NS_ERROR_NOT_AVAILABLE", "Wrong exception"); - } - is (promptState.method, "confirm", "Wrong prompt method called"); - is (promptState.parent, w, "Wrong confirm parent"); - is (promptState.msg, "Prevent this page from creating additional dialogs", - "Wrong confirm message"); - promptState = void(0); - - w.close(); - } - mockPromptFactoryRegisterer.unregister(); mockPromptServiceRegisterer.unregister(); diff --git a/dom/tests/mochitest/bugs/test_bug735237.html b/dom/tests/mochitest/bugs/test_bug735237.html deleted file mode 100644 index e1a25a425..000000000 --- a/dom/tests/mochitest/bugs/test_bug735237.html +++ /dev/null @@ -1,38 +0,0 @@ - - - - - Test for Bug 735237 - - - - -Mozilla Bug 735237 -

- -
-
-
- - diff --git a/dom/tests/mochitest/general/file_showModalDialog.html b/dom/tests/mochitest/general/file_showModalDialog.html deleted file mode 100644 index 1cae0b1c0..000000000 --- a/dom/tests/mochitest/general/file_showModalDialog.html +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - diff --git a/dom/tests/mochitest/general/mochitest.ini b/dom/tests/mochitest/general/mochitest.ini index d00ea1d4b..9f2fad785 100755 --- a/dom/tests/mochitest/general/mochitest.ini +++ b/dom/tests/mochitest/general/mochitest.ini @@ -9,7 +9,6 @@ support-files = file_interfaces.xml file_moving_nodeList.html file_moving_xhr.html - file_showModalDialog.html historyframes.html image_50.png image_100.png @@ -116,8 +115,6 @@ support-files = test_offsets.js [test_resource_timing_frameset.html] [test_selectevents.html] skip-if = toolkit == 'android' # bug 1230232 - Mouse doesn't select in the same way -[test_showModalDialog.html] -skip-if = e10s || toolkit == 'android' #Don't run modal tests on Android [test_showModalDialog_e10s.html] run-if = e10s [test_storagePermissionsAccept.html] diff --git a/dom/tests/mochitest/general/test_showModalDialog.html b/dom/tests/mochitest/general/test_showModalDialog.html deleted file mode 100644 index 511c79e63..000000000 --- a/dom/tests/mochitest/general/test_showModalDialog.html +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - Test for Bug 862918 - - - - - -Mozilla Bug 862918 -

- -
-
- - diff --git a/dom/webidl/Window.webidl b/dom/webidl/Window.webidl index 468f1cc8a..ab03bf40b 100644 --- a/dom/webidl/Window.webidl +++ b/dom/webidl/Window.webidl @@ -78,9 +78,6 @@ typedef any Transferable; [Throws, UnsafeInPrerendering, NeedsSubjectPrincipal] boolean confirm(optional DOMString message = ""); [Throws, UnsafeInPrerendering, NeedsSubjectPrincipal] DOMString? prompt(optional DOMString message = "", optional DOMString default = ""); [Throws, UnsafeInPrerendering] void print(); - //[Throws] any showModalDialog(DOMString url, optional any argument); - [Throws, Func="nsGlobalWindow::IsShowModalDialogEnabled", UnsafeInPrerendering, NeedsSubjectPrincipal] - any showModalDialog(DOMString url, optional any argument, optional DOMString options = ""); [Throws, CrossOriginCallable, NeedsSubjectPrincipal] void postMessage(any message, DOMString targetOrigin, optional sequence transfer); @@ -240,17 +237,6 @@ interface SpeechSynthesisGetter { Window implements SpeechSynthesisGetter; #endif -// http://www.whatwg.org/specs/web-apps/current-work/ -[NoInterfaceObject] -interface WindowModal { - [Throws, Func="nsGlobalWindow::IsModalContentWindow", NeedsSubjectPrincipal] - readonly attribute any dialogArguments; - - [Throws, Func="nsGlobalWindow::IsModalContentWindow", NeedsSubjectPrincipal] - attribute any returnValue; -}; -Window implements WindowModal; - // Mozilla-specific stuff partial interface Window { //[NewObject, Throws] CSSStyleDeclaration getDefaultComputedStyle(Element elt, optional DOMString pseudoElt = ""); diff --git a/embedding/browser/nsIWebBrowserChrome.idl b/embedding/browser/nsIWebBrowserChrome.idl index 40f03cbe4..32dba4219 100644 --- a/embedding/browser/nsIWebBrowserChrome.idl +++ b/embedding/browser/nsIWebBrowserChrome.idl @@ -77,9 +77,6 @@ interface nsIWebBrowserChrome : nsISupports const unsigned long CHROME_NON_PRIVATE_WINDOW = 0x00020000; const unsigned long CHROME_PRIVATE_LIFETIME = 0x00040000; - // Whether this was opened by nsGlobalWindow::ShowModalDialog. - const unsigned long CHROME_MODAL_CONTENT_WINDOW = 0x00080000; - // Whether this window should use remote (out-of-process) tabs. const unsigned long CHROME_REMOTE_WINDOW = 0x00100000; diff --git a/embedding/components/windowwatcher/nsWindowWatcher.cpp b/embedding/components/windowwatcher/nsWindowWatcher.cpp index e0e8b4bef..3732ea66d 100644 --- a/embedding/components/windowwatcher/nsWindowWatcher.cpp +++ b/embedding/components/windowwatcher/nsWindowWatcher.cpp @@ -683,7 +683,6 @@ nsWindowWatcher::OpenWindowInternal(mozIDOMWindowProxy* aParent, bool windowNeedsName = false; bool windowIsModal = false; bool uriToLoadIsChrome = false; - bool windowIsModalContentDialog = false; uint32_t chromeFlags; nsAutoString name; // string version of aName @@ -775,30 +774,12 @@ nsWindowWatcher::OpenWindowInternal(mozIDOMWindowProxy* aParent, } else { chromeFlags = CalculateChromeFlagsForChild(features); - // Until ShowModalDialog is removed, it's still possible for content to - // request dialogs, but only in single-process mode. if (aDialog) { MOZ_ASSERT(XRE_IsParentProcess()); chromeFlags |= nsIWebBrowserChrome::CHROME_OPENAS_DIALOG; } } - // If we're not called through our JS version of the API, and we got - // our internal modal option, treat the window we're opening as a - // modal content window (and set the modal chrome flag). - if (!aCalledFromJS && aArgv && - WinHasOption(features, "-moz-internal-modal", 0, nullptr)) { - windowIsModalContentDialog = true; - - // CHROME_MODAL gets inherited by dependent windows, which affects various - // platform-specific window state (especially on OSX). So we need some way - // to determine that this window was actually opened by nsGlobalWindow:: - // ShowModalDialog(), and that somebody is actually going to be watching - // for return values and all that. - chromeFlags |= nsIWebBrowserChrome::CHROME_MODAL_CONTENT_WINDOW; - chromeFlags |= nsIWebBrowserChrome::CHROME_MODAL; - } - SizeSpec sizeSpec; CalcSizeSpec(features, sizeSpec); @@ -1079,7 +1060,7 @@ nsWindowWatcher::OpenWindowInternal(mozIDOMWindowProxy* aParent, MaybeDisablePersistence(features, newTreeOwner); } - if ((aDialog || windowIsModalContentDialog) && aArgv) { + if (aDialog && aArgv) { // Set the args on the new window. nsCOMPtr piwin(do_QueryInterface(*aResult)); NS_ENSURE_TRUE(piwin, NS_ERROR_UNEXPECTED); @@ -1268,8 +1249,7 @@ nsWindowWatcher::OpenWindowInternal(mozIDOMWindowProxy* aParent, SizeOpenedWindow(newTreeOwner, aParent, isCallerChrome, sizeSpec); } - // XXXbz isn't windowIsModal always true when windowIsModalContentDialog? - if (windowIsModal || windowIsModalContentDialog) { + if (windowIsModal) { nsCOMPtr newTreeOwner; newDocShellItem->GetTreeOwner(getter_AddRefs(newTreeOwner)); nsCOMPtr newChrome(do_GetInterface(newTreeOwner)); diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index 8f7ae0a58..c5daf9213 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -1166,7 +1166,6 @@ pref("dom.disable_window_open_feature.menubar", false); pref("dom.disable_window_open_feature.resizable", true); pref("dom.disable_window_open_feature.minimizable", false); pref("dom.disable_window_open_feature.status", true); -pref("dom.disable_window_showModalDialog", true); pref("dom.allow_scripts_to_close_windows", false); -- cgit v1.2.3 From 3624078103303adf0b934734d95a1ed9eb7bfefd Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Wed, 22 Jan 2020 21:42:10 +0100 Subject: Issue #1366 - Fix build bustage from erroneously removing 2 function implementations. --- dom/base/nsGlobalWindow.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 0587eb892..dd1fe4586 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -14456,6 +14456,20 @@ nsGlobalChromeWindow::TakeOpenerForInitialContentBrowser(mozIDOMWindowProxy** aO return NS_OK; } +/* static */ already_AddRefed +nsGlobalWindow::Create(nsGlobalWindow *aOuterWindow) +{ + RefPtr window = new nsGlobalWindow(aOuterWindow); + window->InitWasOffline(); + return window.forget(); +} + +void +nsGlobalWindow::InitWasOffline() +{ + mWasOffline = NS_IsOffline(); +} + #if defined(MOZ_WIDGET_ANDROID) int16_t nsGlobalWindow::Orientation(CallerType aCallerType) const -- cgit v1.2.3 From 90c5288fef22004d6e4d441b3ae10b9cd1836103 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Thu, 23 Jan 2020 13:08:02 +0100 Subject: Issue #1342 - Remove support for system libevent --- build/directive4.py | 1 - config/Makefile.in | 1 - config/system-headers | 4 --- ipc/chromium/moz.build | 6 ++-- .../src/third_party/libeventcommon.mozbuild | 2 +- ipc/chromium/src/third_party/moz.build | 3 -- old-configure.in | 39 ---------------------- toolkit/library/moz.build | 3 -- 8 files changed, 4 insertions(+), 55 deletions(-) diff --git a/build/directive4.py b/build/directive4.py index 28d84973e..bb832f6b7 100644 --- a/build/directive4.py +++ b/build/directive4.py @@ -33,7 +33,6 @@ if ('MOZ_OFFICIAL_BRANDING' in listConfig) or (strBrandingDirectory.endswith("br # Applies to Pale Moon and Basilisk if ('MC_BASILISK' in listConfig) or ('MC_PALEMOON' in listConfig): listViolations += [ - 'MOZ_SYSTEM_LIBEVENT', 'MOZ_SYSTEM_NSS', 'MOZ_SYSTEM_NSPR', 'MOZ_SYSTEM_JPEG', diff --git a/config/Makefile.in b/config/Makefile.in index 10807cfb9..1512520e4 100644 --- a/config/Makefile.in +++ b/config/Makefile.in @@ -46,7 +46,6 @@ export:: $(export-preqs) -DMOZ_SYSTEM_ZLIB=$(MOZ_SYSTEM_ZLIB) \ -DMOZ_SYSTEM_PNG=$(MOZ_SYSTEM_PNG) \ -DMOZ_SYSTEM_JPEG=$(MOZ_SYSTEM_JPEG) \ - -DMOZ_SYSTEM_LIBEVENT=$(MOZ_SYSTEM_LIBEVENT) \ -DMOZ_SYSTEM_LIBVPX=$(MOZ_SYSTEM_LIBVPX) \ -DMOZ_SYSTEM_ICU=$(MOZ_SYSTEM_ICU) \ $(srcdir)/system-headers $(srcdir)/stl-headers | $(PERL) $(topsrcdir)/nsprpub/config/make-system-wrappers.pl system_wrappers diff --git a/config/system-headers b/config/system-headers index b10324f0f..29eef3210 100644 --- a/config/system-headers +++ b/config/system-headers @@ -1276,11 +1276,7 @@ bzlib.h #ifdef MOZ_ENABLE_GIO gio/gio.h #endif -#if MOZ_SYSTEM_LIBEVENT==1 -event.h -#else sys/event.h -#endif #ifdef MOZ_ENABLE_LIBPROXY proxy.h #endif diff --git a/ipc/chromium/moz.build b/ipc/chromium/moz.build index dc5b4dca4..b386134f9 100644 --- a/ipc/chromium/moz.build +++ b/ipc/chromium/moz.build @@ -58,7 +58,7 @@ if os_win: 'src/chrome/common/process_watcher_win.cc', 'src/chrome/common/transport_dib_win.cc', ] -elif not CONFIG['MOZ_SYSTEM_LIBEVENT']: +else: DIRS += ['src/third_party'] if os_posix: @@ -143,9 +143,9 @@ if os_solaris: 'src/base/atomicops_internals_x86_gcc.cc', 'src/base/process_util_linux.cc', 'src/base/time_posix.cc', -] + ] -elif not CONFIG['MOZ_SYSTEM_LIBEVENT']: +else: LOCAL_INCLUDES += ['src/third_party/libevent/linux'] ost = CONFIG['OS_TEST'] diff --git a/ipc/chromium/src/third_party/libeventcommon.mozbuild b/ipc/chromium/src/third_party/libeventcommon.mozbuild index 2b45ecb19..33482c661 100644 --- a/ipc/chromium/src/third_party/libeventcommon.mozbuild +++ b/ipc/chromium/src/third_party/libeventcommon.mozbuild @@ -32,7 +32,7 @@ else: else: libevent_include_suffix = 'linux' -if os_posix and not CONFIG['MOZ_SYSTEM_LIBEVENT']: +if os_posix: DEFINES['HAVE_CONFIG_H'] = True LOCAL_INCLUDES += sorted([ 'libevent', diff --git a/ipc/chromium/src/third_party/moz.build b/ipc/chromium/src/third_party/moz.build index 2b99e53b3..20a5043fb 100644 --- a/ipc/chromium/src/third_party/moz.build +++ b/ipc/chromium/src/third_party/moz.build @@ -10,9 +10,6 @@ include(libevent_path_prefix + '/libeventcommon.mozbuild') if os_win: error('should not reach here on Windows') -if CONFIG['MOZ_SYSTEM_LIBEVENT']: - error('should not reach here if we are using a native libevent') - UNIFIED_SOURCES += [ 'libevent/buffer.c', 'libevent/bufferevent.c', diff --git a/old-configure.in b/old-configure.in index 9398ef0fc..a98951937 100644 --- a/old-configure.in +++ b/old-configure.in @@ -2005,44 +2005,6 @@ esac MOZ_CONFIG_NSPR() -dnl ======================================================== -dnl system libevent Support -dnl ======================================================== -MOZ_ARG_WITH_STRING(system-libevent, -[ --with-system-libevent[=PFX] - Use system libevent [installed at prefix PFX]], - LIBEVENT_DIR=$withval) - -_SAVE_CFLAGS=$CFLAGS -_SAVE_LDFLAGS=$LDFLAGS -_SAVE_LIBS=$LIBS -if test "$LIBEVENT_DIR" = yes; then - PKG_CHECK_MODULES(MOZ_LIBEVENT, libevent, - MOZ_SYSTEM_LIBEVENT=1, - LIBEVENT_DIR=/usr) -fi -if test -z "$LIBEVENT_DIR" -o "$LIBEVENT_DIR" = no; then - MOZ_SYSTEM_LIBEVENT= -elif test -z "$MOZ_SYSTEM_LIBEVENT"; then - CFLAGS="-I${LIBEVENT_DIR}/include $CFLAGS" - LDFLAGS="-L${LIBEVENT_DIR}/lib $LDFLAGS" - MOZ_CHECK_HEADER(event.h, - [if test ! -f "${LIBEVENT_DIR}/include/event.h"; then - AC_MSG_ERROR([event.h found, but is not in ${LIBEVENT_DIR}/include]) - fi], - AC_MSG_ERROR([--with-system-libevent requested but event.h not found])) - AC_CHECK_LIB(event, event_init, - [MOZ_SYSTEM_LIBEVENT=1 - MOZ_LIBEVENT_CFLAGS="-I${LIBEVENT_DIR}/include" - MOZ_LIBEVENT_LIBS="-L${LIBEVENT_DIR}/lib -levent"], - [MOZ_SYSTEM_LIBEVENT= MOZ_LIBEVENT_CFLAGS= MOZ_LIBEVENT_LIBS=]) -fi -CFLAGS=$_SAVE_CFLAGS -LDFLAGS=$_SAVE_LDFLAGS -LIBS=$_SAVE_LIBS - -AC_SUBST(MOZ_SYSTEM_LIBEVENT) - dnl ======================================================== dnl = If NSS was not detected in the system, dnl = use the one in the source tree (mozilla/security/nss) @@ -5624,7 +5586,6 @@ MC_BASILISK=$MC_BASILISK MC_PALEMOON=$MC_PALEMOON MOZ_EME=$MOZ_EME MOZ_WEBRTC=$MOZ_WEBRTC -MOZ_SYSTEM_LIBEVENT=$MOZ_SYSTEM_LIBEVENT MOZ_SYSTEM_NSS=$MOZ_SYSTEM_NSS MOZ_SYSTEM_NSPR=$MOZ_SYSTEM_NSPR MOZ_SYSTEM_JPEG=$MOZ_SYSTEM_JPEG diff --git a/toolkit/library/moz.build b/toolkit/library/moz.build index ebba07b4a..85a7351ba 100644 --- a/toolkit/library/moz.build +++ b/toolkit/library/moz.build @@ -201,9 +201,6 @@ if CONFIG['MOZ_SYSTEM_PNG']: if CONFIG['MOZ_SYSTEM_HUNSPELL']: OS_LIBS += CONFIG['MOZ_HUNSPELL_LIBS'] -if CONFIG['MOZ_SYSTEM_LIBEVENT']: - OS_LIBS += CONFIG['MOZ_LIBEVENT_LIBS'] - if CONFIG['MOZ_SYSTEM_LIBVPX']: OS_LIBS += CONFIG['MOZ_LIBVPX_LIBS'] -- cgit v1.2.3 From 6d761aa68fd6d3ae91ad4fb34c80c85d7e665c79 Mon Sep 17 00:00:00 2001 From: Kai Engert Date: Thu, 23 Jan 2020 13:11:09 +0100 Subject: Issue #1338 - Follow-up: Also cache the most recent PBKDF1 hash This rewrites the caching mechanism to apply to both PBKDF1 and PBKDF2 --- security/nss/lib/softoken/lowpbe.c | 190 +++++++++++++++++++++++++++---------- 1 file changed, 140 insertions(+), 50 deletions(-) diff --git a/security/nss/lib/softoken/lowpbe.c b/security/nss/lib/softoken/lowpbe.c index 86b55fd9b..55808f0f7 100644 --- a/security/nss/lib/softoken/lowpbe.c +++ b/security/nss/lib/softoken/lowpbe.c @@ -554,50 +554,160 @@ loser: return A; } +struct KDFCacheItemStr { + SECItem *hash; + SECItem *salt; + SECItem *pwItem; + HASH_HashType hashType; + int iterations; + int keyLen; +}; +typedef struct KDFCacheItemStr KDFCacheItem; + /* Bug 1606992 - Cache the hash result for the common case that we're * asked to repeatedly compute the key for the same password item, * hash, iterations and salt. */ -static PZLock *PBE_cache_lock = NULL; -static SECItem *cached_PBKDF2_item = NULL; -static HASH_HashType cached_hashType; -static int cached_iterations; -static int cached_keyLen; -static SECItem *cached_salt = NULL; -static SECItem *cached_pwitem = NULL; +static struct { + PZLock *lock; + struct { + KDFCacheItem common; + int ivLen; + PRBool faulty3DES; + } cacheKDF1; + struct { + KDFCacheItem common; + } cacheKDF2; +} PBECache; void sftk_PBELockInit(void) { - if (!PBE_cache_lock) { - PBE_cache_lock = PZ_NewLock(nssIPBECacheLock); + if (!PBECache.lock) { + PBECache.lock = PZ_NewLock(nssIPBECacheLock); } } static void -sftk_clearPBECacheItems(void) +sftk_clearPBECommonCacheItemsLocked(KDFCacheItem *item) { - if (cached_PBKDF2_item) { - SECITEM_FreeItem(cached_PBKDF2_item, PR_TRUE); - cached_PBKDF2_item = NULL; + if (item->hash) { + SECITEM_ZfreeItem(item->hash, PR_TRUE); + item->hash = NULL; } - if (cached_salt) { - SECITEM_FreeItem(cached_salt, PR_TRUE); - cached_salt = NULL; + if (item->salt) { + SECITEM_FreeItem(item->salt, PR_TRUE); + item->salt = NULL; } - if (cached_pwitem) { - SECITEM_FreeItem(cached_pwitem, PR_TRUE); - cached_pwitem = NULL; + if (item->pwItem) { + SECITEM_ZfreeItem(item->pwItem, PR_TRUE); + item->pwItem = NULL; } } +sftk_setPBECommonCacheItemsKDFLocked(KDFCacheItem *cacheItem, + const SECItem *hash, + const NSSPKCS5PBEParameter *pbe_param, + const SECItem *pwItem) +{ + cacheItem->hash = SECITEM_DupItem(hash); + cacheItem->hashType = pbe_param->hashType; + cacheItem->iterations = pbe_param->iter; + cacheItem->keyLen = pbe_param->keyLen; + cacheItem->salt = SECITEM_DupItem(&pbe_param->salt); + cacheItem->pwItem = SECITEM_DupItem(pwItem); +} + +static void +sftk_setPBECacheKDF2(const SECItem *hash, + const NSSPKCS5PBEParameter *pbe_param, + const SECItem *pwItem) +{ + PZ_Lock(PBECache.lock); + sftk_clearPBECommonCacheItemsLocked(&PBECache.cacheKDF2.common); + sftk_setPBECommonCacheItemsKDFLocked(&PBECache.cacheKDF2.common, + hash, pbe_param, pwItem); + + PZ_Unlock(PBECache.lock); +} + +static void +sftk_setPBECacheKDF1(const SECItem *hash, + const NSSPKCS5PBEParameter *pbe_param, + const SECItem *pwItem, + PRBool faulty3DES) +{ + PZ_Lock(PBECache.lock); + + sftk_clearPBECommonCacheItemsLocked(&PBECache.cacheKDF1.common); + + sftk_setPBECommonCacheItemsKDFLocked(&PBECache.cacheKDF1.common, + hash, pbe_param, pwItem); + PBECache.cacheKDF1.faulty3DES = faulty3DES; + PBECache.cacheKDF1.ivLen = pbe_param->ivLen; + + PZ_Unlock(PBECache.lock); +} + +static PRBool +sftk_comparePBECommonCacheItemLocked(const KDFCacheItem *cacheItem, + const NSSPKCS5PBEParameter *pbe_param, + const SECItem *pwItem) +{ + return (cacheItem->hash && + cacheItem->salt && + cacheItem->pwItem && + pbe_param->hashType == cacheItem->hashType && + pbe_param->iter == cacheItem->iterations && + pbe_param->keyLen == cacheItem->keyLen && + SECITEM_ItemsAreEqual(&pbe_param->salt, cacheItem->salt) && + SECITEM_ItemsAreEqual(pwItem, cacheItem->pwItem)); +} + +static SECItem * +sftk_getPBECacheKDF2(const NSSPKCS5PBEParameter *pbe_param, + const SECItem *pwItem) +{ + SECItem *result = NULL; + const KDFCacheItem *cacheItem = &PBECache.cacheKDF2.common; + + PZ_Lock(PBECache.lock); + if (sftk_comparePBECommonCacheItemLocked(cacheItem, pbe_param, pwItem)) { + result = SECITEM_DupItem(cacheItem->hash); + } + PZ_Unlock(PBECache.lock); + + return result; +} + +static SECItem * +sftk_getPBECacheKDF1(const NSSPKCS5PBEParameter *pbe_param, + const SECItem *pwItem, + PRBool faulty3DES) +{ + SECItem *result = NULL; + const KDFCacheItem *cacheItem = &PBECache.cacheKDF1.common; + + PZ_Lock(PBECache.lock); + if (sftk_comparePBECommonCacheItemLocked(cacheItem, pbe_param, pwItem) && + PBECache.cacheKDF1.faulty3DES == faulty3DES && + PBECache.cacheKDF1.ivLen == pbe_param->ivLen) { + result = SECITEM_DupItem(cacheItem->hash); + } + PZ_Unlock(PBECache.lock); + + return result; +} + + void sftk_PBELockShutdown(void) { - if (PBE_cache_lock) { - PZ_DestroyLock(PBE_cache_lock); - PBE_cache_lock = 0; + if (PBECache.lock) { + PZ_DestroyLock(PBECache.lock); + PBECache.lock = 0; } - sftk_clearPBECacheItems(); + sftk_clearPBECommonCacheItemsLocked(&PBECache.cacheKDF1.common); + sftk_clearPBECommonCacheItemsLocked(&PBECache.cacheKDF2.common); } /* @@ -632,7 +742,11 @@ nsspkcs5_ComputeKeyAndIV(NSSPKCS5PBEParameter *pbe_param, SECItem *pwitem, hashObj = HASH_GetRawHashObject(pbe_param->hashType); switch (pbe_param->pbeType) { case NSSPKCS5_PBKDF1: - hash = nsspkcs5_PBKDF1Extended(hashObj, pbe_param, pwitem, faulty3DES); + hash = sftk_getPBECacheKDF1(pbe_param, pwitem, faulty3DES); + if (!hash) { + hash = nsspkcs5_PBKDF1Extended(hashObj, pbe_param, pwitem, faulty3DES); + sftk_setPBECacheKDF1(hash, pbe_param, pwitem, faulty3DES); + } if (hash == NULL) { goto loser; } @@ -643,34 +757,10 @@ nsspkcs5_ComputeKeyAndIV(NSSPKCS5PBEParameter *pbe_param, SECItem *pwitem, break; case NSSPKCS5_PBKDF2: - PZ_Lock(PBE_cache_lock); - if (cached_PBKDF2_item) { - if (pbe_param->hashType == cached_hashType && - pbe_param->iter == cached_iterations && - pbe_param->keyLen == cached_keyLen && - cached_salt && - SECITEM_ItemsAreEqual(&pbe_param->salt, cached_salt) && - cached_pwitem && - SECITEM_ItemsAreEqual(pwitem, cached_pwitem)) { - hash = SECITEM_DupItem(cached_PBKDF2_item); - } else { - sftk_clearPBECacheItems(); - } - } - PZ_Unlock(PBE_cache_lock); + hash = sftk_getPBECacheKDF2(pbe_param, pwitem); if (!hash) { hash = nsspkcs5_PBKDF2(hashObj, pbe_param, pwitem); - PZ_Lock(PBE_cache_lock); - /* ensure no other thread was quicker than us setting the cache */ - if (!cached_PBKDF2_item) { - cached_PBKDF2_item = SECITEM_DupItem(hash); - cached_hashType = pbe_param->hashType; - cached_iterations = pbe_param->iter; - cached_keyLen = pbe_param->keyLen; - cached_salt = SECITEM_DupItem(&pbe_param->salt); - cached_pwitem = SECITEM_DupItem(pwitem); - } - PZ_Unlock(PBE_cache_lock); + sftk_setPBECacheKDF2(hash, pbe_param, pwitem); } if (getIV) { PORT_Memcpy(iv->data, pbe_param->ivData, iv->len); -- cgit v1.2.3 From a64ac6d7022e4c88149d897864f857dce1063249 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Thu, 23 Jan 2020 15:17:51 +0100 Subject: No issue - Always use jemalloc allocator for storage memory when MOZ_MEMORY is defined (which is defined by enabling jemalloc in config) --- storage/moz.build | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/storage/moz.build b/storage/moz.build index 216a1cf74..5ccfabd71 100644 --- a/storage/moz.build +++ b/storage/moz.build @@ -88,17 +88,10 @@ FINAL_LIBRARY = 'xul' # Don't use the jemalloc allocator on Android, because we can't guarantee # that Gecko will configure sqlite before it is first used (bug 730495). # -# Don't use the jemalloc allocator when using system sqlite. Linked in libraries -# (such as NSS) might trigger an initialization of sqlite and allocation -# of memory using the default allocator, prior to the storage service -# registering its allocator, causing memory management failures (bug 938730). -# However, this is not an issue if both the jemalloc allocator and the default -# allocator are the same thing. -# # Note: On Windows our sqlite build assumes we use jemalloc. If you disable # MOZ_STORAGE_MEMORY on Windows, you will also need to change the "ifdef # MOZ_MEMORY" options in db/sqlite3/src/Makefile.in. -if CONFIG['MOZ_MEMORY'] and not CONFIG['MOZ_SYSTEM_SQLITE']: +if CONFIG['MOZ_MEMORY']: if CONFIG['OS_TARGET'] != 'Android': DEFINES['MOZ_STORAGE_MEMORY'] = True -- cgit v1.2.3 From 8bb5db350d302f12aff7688a850ee51885e0e803 Mon Sep 17 00:00:00 2001 From: athenian200 Date: Sun, 26 Jan 2020 01:40:55 -0600 Subject: Issue #1349 - Stop 2xx FTP responses from causing browser to hang. LIST and RETR still appear to work as intended on ftp:// URLs after my changes. I wasn't able to test STOR because the browser doesn't appear to support FTP uploads at this time (although our FTP implementation appears perfectly capable of doing an FTP upload.) If I understood the issue correctly, though, what we're doing is ensuring that we receive a preliminary 100 response from the FTP server for a given action before jumping to the 200 code describing what we do if the action was completed. Even though it makes no logical sense for a server to say an action was completed before it was initiated, someone could write a really annoying FTP server that takes advantage of this fact to crash the browser if they wanted. --- netwerk/protocol/ftp/nsFtpConnectionThread.cpp | 18 ++++++++++++++---- netwerk/protocol/ftp/nsFtpConnectionThread.h | 6 ++++++ 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/netwerk/protocol/ftp/nsFtpConnectionThread.cpp b/netwerk/protocol/ftp/nsFtpConnectionThread.cpp index 0dae7ca92..6904bc33b 100644 --- a/netwerk/protocol/ftp/nsFtpConnectionThread.cpp +++ b/netwerk/protocol/ftp/nsFtpConnectionThread.cpp @@ -82,6 +82,9 @@ nsFtpState::nsFtpState() , mAnonymous(true) , mRetryPass(false) , mStorReplyReceived(false) + , mRlist1xxReceived(false) + , mRstor1xxReceived(false) + , mRretr1xxReceived(false) , mInternalError(NS_OK) , mReconnectAndLoginAgain(false) , mCacheConnection(true) @@ -1153,15 +1156,18 @@ nsFtpState::S_list() { FTP_STATE nsFtpState::R_list() { if (mResponseCode/100 == 1) { + mRlist1xxReceived = true; + // OK, time to start reading from the data connection. if (mDataStream && HasPendingCallback()) mDataStream->AsyncWait(this, 0, 0, CallbackTarget()); return FTP_READ_BUF; } - if (mResponseCode/100 == 2) { + if (mResponseCode/100 == 2 && mRlist1xxReceived) { //(DONE) mNextState = FTP_COMPLETE; + mRlist1xxReceived = false; return FTP_COMPLETE; } return FTP_ERROR; @@ -1181,13 +1187,16 @@ nsFtpState::S_retr() { FTP_STATE nsFtpState::R_retr() { - if (mResponseCode/100 == 2) { + if (mResponseCode/100 == 2 && mRretr1xxReceived) { //(DONE) mNextState = FTP_COMPLETE; + mRretr1xxReceived = false; return FTP_COMPLETE; } if (mResponseCode/100 == 1) { + mRretr1xxReceived = true; + if (mDataStream && HasPendingCallback()) mDataStream->AsyncWait(this, 0, 0, CallbackTarget()); return FTP_READ_BUF; @@ -1262,7 +1271,7 @@ nsFtpState::S_stor() { FTP_STATE nsFtpState::R_stor() { - if (mResponseCode/100 == 2) { + if (mResponseCode/100 == 2 && mRstor1xxReceived) { //(DONE) mNextState = FTP_COMPLETE; mStorReplyReceived = true; @@ -1270,11 +1279,12 @@ nsFtpState::R_stor() { // Call Close() if it was not called in nsFtpState::OnStoprequest() if (!mUploadRequest && !IsClosed()) Close(); - + mRstor1xxReceived = false; return FTP_COMPLETE; } if (mResponseCode/100 == 1) { + mRstor1xxReceived = true; LOG(("FTP:(%x) writing on DT\n", this)); return FTP_READ_BUF; } diff --git a/netwerk/protocol/ftp/nsFtpConnectionThread.h b/netwerk/protocol/ftp/nsFtpConnectionThread.h index b4e71bd10..cc8f0df95 100644 --- a/netwerk/protocol/ftp/nsFtpConnectionThread.h +++ b/netwerk/protocol/ftp/nsFtpConnectionThread.h @@ -180,6 +180,12 @@ private: bool mRetryPass; // retrying the password bool mStorReplyReceived; // FALSE if waiting for STOR // completion status from server + bool mRlist1xxReceived; // TRUE if the server has sent a + // LIST 1xx response. + bool mRstor1xxReceived; // TRUE if the server has sent a + // STOR 1xx response. + bool mRretr1xxReceived; // TRUE if the server has sent a + // RETR 1xx response. nsresult mInternalError; // represents internal state errors bool mReconnectAndLoginAgain; bool mCacheConnection; -- cgit v1.2.3 From 7d53919c26e7b1126d2b0bd534ec7299fc34f040 Mon Sep 17 00:00:00 2001 From: athenian200 Date: Sun, 26 Jan 2020 01:51:37 -0600 Subject: Fix whitespace. --- netwerk/protocol/ftp/nsFtpConnectionThread.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netwerk/protocol/ftp/nsFtpConnectionThread.h b/netwerk/protocol/ftp/nsFtpConnectionThread.h index cc8f0df95..2fe21ab8c 100644 --- a/netwerk/protocol/ftp/nsFtpConnectionThread.h +++ b/netwerk/protocol/ftp/nsFtpConnectionThread.h @@ -181,7 +181,7 @@ private: bool mStorReplyReceived; // FALSE if waiting for STOR // completion status from server bool mRlist1xxReceived; // TRUE if the server has sent a - // LIST 1xx response. + // LIST 1xx response. bool mRstor1xxReceived; // TRUE if the server has sent a // STOR 1xx response. bool mRretr1xxReceived; // TRUE if the server has sent a -- cgit v1.2.3 From 282b791acb826de9b537fce88bf49472d8e19977 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Sat, 25 Jan 2020 21:26:24 +0100 Subject: Issue #1360 - Part 1: Simplify layers acceleration prefs. This gets rid of platform-dependent hard-coded defaults, but keeps build-time blocking if there is no GL provider (in which case layers acceleration almost certainly won't work because it needs a GL compositor and would likely crash without) New prefs are - layers.acceleration.enabled to enable HWA - layers.acceleration.force to force it enabled (requires .enabled to be set as well) This is the platform part of this issue. The rest will be front-end work (Preference UI integration and pref migration) --- gfx/thebes/gfxAndroidPlatform.h | 5 ----- gfx/thebes/gfxPlatform.cpp | 41 ++++------------------------------------- gfx/thebes/gfxPlatform.h | 2 +- gfx/thebes/gfxPlatformGtk.h | 4 ---- gfx/thebes/gfxPlatformMac.cpp | 6 ------ gfx/thebes/gfxPlatformMac.h | 3 --- gfx/thebes/gfxPrefs.h | 4 ++-- gfx/thebes/gfxWindowsPlatform.h | 3 --- modules/libpref/init/all.js | 23 ++++++++++------------- 9 files changed, 17 insertions(+), 74 deletions(-) diff --git a/gfx/thebes/gfxAndroidPlatform.h b/gfx/thebes/gfxAndroidPlatform.h index 30e7c89ba..8975d0ab9 100644 --- a/gfx/thebes/gfxAndroidPlatform.h +++ b/gfx/thebes/gfxAndroidPlatform.h @@ -72,11 +72,6 @@ public: return true; } -protected: - bool AccelerateLayersByDefault() override { - return true; - } - private: gfxImageFormat mOffscreenFormat; }; diff --git a/gfx/thebes/gfxPlatform.cpp b/gfx/thebes/gfxPlatform.cpp index 50d1fcb46..4cd044f90 100644 --- a/gfx/thebes/gfxPlatform.cpp +++ b/gfx/thebes/gfxPlatform.cpp @@ -571,40 +571,6 @@ gfxPlatform::Init() } } - // Drop a note in the crash report if we end up forcing an option that could - // destabilize things. New items should be appended at the end (of an existing - // or in a new section), so that we don't have to know the version to interpret - // these cryptic strings. - { - nsAutoCString forcedPrefs; - // D2D prefs - forcedPrefs.AppendPrintf("FP(D%d%d", - gfxPrefs::Direct2DDisabled(), - gfxPrefs::Direct2DForceEnabled()); - // Layers prefs - forcedPrefs.AppendPrintf("-L%d%d%d%d", - gfxPrefs::LayersAMDSwitchableGfxEnabled(), - gfxPrefs::LayersAccelerationDisabledDoNotUseDirectly(), - gfxPrefs::LayersAccelerationForceEnabledDoNotUseDirectly(), - gfxPrefs::LayersD3D11ForceWARP()); - // WebGL prefs - forcedPrefs.AppendPrintf("-W%d%d%d%d%d%d%d%d", - gfxPrefs::WebGLANGLEForceD3D11(), - gfxPrefs::WebGLANGLEForceWARP(), - gfxPrefs::WebGLDisabled(), - gfxPrefs::WebGLDisableANGLE(), - gfxPrefs::WebGLDXGLEnabled(), - gfxPrefs::WebGLForceEnabled(), - gfxPrefs::WebGLForceLayersReadback(), - gfxPrefs::WebGLForceMSAA()); - // Prefs that don't fit into any of the other sections - forcedPrefs.AppendPrintf("-T%d%d%d%d) ", - gfxPrefs::AndroidRGB16Force(), - gfxPrefs::CanvasAzureAccelerated(), - gfxPrefs::DisableGralloc(), - gfxPrefs::ForceShmemTiles()); - } - InitMoz2DLogging(); gGfxPlatformPrefsLock = new Mutex("gfxPlatform::gGfxPlatformPrefsLock"); @@ -2171,7 +2137,7 @@ gfxPlatform::InitCompositorAccelerationPrefs() FeatureStatus::Blocked, "Acceleration blocked by platform")) { - if (gfxPrefs::LayersAccelerationDisabledDoNotUseDirectly()) { + if (!gfxPrefs::LayersAccelerationEnabledDoNotUseDirectly()) { feature.UserDisable("Disabled by pref", NS_LITERAL_CSTRING("FEATURE_FAILURE_COMP_PREF")); } else if (acceleratedEnv && *acceleratedEnv == '0') { @@ -2185,8 +2151,9 @@ gfxPlatform::InitCompositorAccelerationPrefs() } // This has specific meaning elsewhere, so we always record it. - if (gfxPrefs::LayersAccelerationForceEnabledDoNotUseDirectly()) { - feature.UserForceEnable("Force-enabled by pref"); + if (gfxPrefs::LayersAccelerationEnabledDoNotUseDirectly() && + gfxPrefs::LayersAccelerationForceEnabledDoNotUseDirectly()) { + feature.UserForceEnable("Force-enabled by prefs"); } // Safe mode trumps everything. diff --git a/gfx/thebes/gfxPlatform.h b/gfx/thebes/gfxPlatform.h index 68bb99ea4..642cf909f 100644 --- a/gfx/thebes/gfxPlatform.h +++ b/gfx/thebes/gfxPlatform.h @@ -698,7 +698,7 @@ protected: virtual already_AddRefed CreateHardwareVsyncSource(); // Returns whether or not layers should be accelerated by default on this platform. - virtual bool AccelerateLayersByDefault(); + bool AccelerateLayersByDefault(); // Returns a prioritized list of available compositor backends for acceleration. virtual void GetAcceleratedCompositorBackends(nsTArray& aBackends); diff --git a/gfx/thebes/gfxPlatformGtk.h b/gfx/thebes/gfxPlatformGtk.h index 9959c0e13..22ed4b08f 100644 --- a/gfx/thebes/gfxPlatformGtk.h +++ b/gfx/thebes/gfxPlatformGtk.h @@ -132,10 +132,6 @@ public: return true; } - bool AccelerateLayersByDefault() override { - return true; - } - #ifdef GL_PROVIDER_GLX already_AddRefed CreateHardwareVsyncSource() override; #endif diff --git a/gfx/thebes/gfxPlatformMac.cpp b/gfx/thebes/gfxPlatformMac.cpp index 79684dd19..75c5236a8 100644 --- a/gfx/thebes/gfxPlatformMac.cpp +++ b/gfx/thebes/gfxPlatformMac.cpp @@ -372,12 +372,6 @@ gfxPlatformMac::ReadAntiAliasingThreshold() return threshold; } -bool -gfxPlatformMac::AccelerateLayersByDefault() -{ - return true; -} - // This is the renderer output callback function, called on the vsync thread static CVReturn VsyncCallback(CVDisplayLinkRef aDisplayLink, const CVTimeStamp* aNow, diff --git a/gfx/thebes/gfxPlatformMac.h b/gfx/thebes/gfxPlatformMac.h index 0807614f6..ea4c1a101 100644 --- a/gfx/thebes/gfxPlatformMac.h +++ b/gfx/thebes/gfxPlatformMac.h @@ -81,9 +81,6 @@ public: // lower threshold on font anti-aliasing uint32_t GetAntiAliasingThreshold() { return mFontAntiAliasingThreshold; } -protected: - bool AccelerateLayersByDefault() override; - private: virtual void GetPlatformCMSOutputProfile(void* &mem, size_t &size) override; diff --git a/gfx/thebes/gfxPrefs.h b/gfx/thebes/gfxPrefs.h index 1253fdb48..d02f15699 100644 --- a/gfx/thebes/gfxPrefs.h +++ b/gfx/thebes/gfxPrefs.h @@ -448,11 +448,11 @@ private: DECL_GFX_PREF(Once, "image.multithreaded_decoding.limit", ImageMTDecodingLimit, int32_t, -1); DECL_GFX_PREF(Live, "image.webp.enabled", ImageWebPEnabled, bool, true); - DECL_GFX_PREF(Once, "layers.acceleration.disabled", LayersAccelerationDisabledDoNotUseDirectly, bool, false); + DECL_GFX_PREF(Once, "layers.acceleration.enabled", LayersAccelerationEnabledDoNotUseDirectly, bool, true); DECL_GFX_PREF(Live, "layers.acceleration.draw-fps", LayersDrawFPS, bool, false); DECL_GFX_PREF(Live, "layers.acceleration.draw-fps.print-histogram", FPSPrintHistogram, bool, false); DECL_GFX_PREF(Live, "layers.acceleration.draw-fps.write-to-file", WriteFPSToFile, bool, false); - DECL_GFX_PREF(Once, "layers.acceleration.force-enabled", LayersAccelerationForceEnabledDoNotUseDirectly, bool, false); + DECL_GFX_PREF(Once, "layers.acceleration.force", LayersAccelerationForceEnabledDoNotUseDirectly, bool, false); DECL_GFX_PREF(Once, "layers.allow-d3d9-fallback", LayersAllowD3D9Fallback, bool, false); DECL_GFX_PREF(Once, "layers.amd-switchable-gfx.enabled", LayersAMDSwitchableGfxEnabled, bool, false); DECL_GFX_PREF(Once, "layers.async-pan-zoom.enabled", AsyncPanZoomEnabledDoNotUseDirectly, bool, true); diff --git a/gfx/thebes/gfxWindowsPlatform.h b/gfx/thebes/gfxWindowsPlatform.h index 129365f82..b56dab338 100644 --- a/gfx/thebes/gfxWindowsPlatform.h +++ b/gfx/thebes/gfxWindowsPlatform.h @@ -226,9 +226,6 @@ public: bool SupportsPluginDirectDXGIDrawing(); protected: - bool AccelerateLayersByDefault() override { - return true; - } void GetAcceleratedCompositorBackends(nsTArray& aBackends) override; virtual void GetPlatformCMSOutputProfile(void* &mem, size_t &size) override; diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index c5daf9213..ada4dbc5f 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -4497,7 +4497,16 @@ pref("network.tcp.keepalive.probe_count", 4); #endif // Whether to disable acceleration for all widgets. -pref("layers.acceleration.disabled", false); +#if defined(XP_UNIX) && !defined(XP_MACOSX) +// On Linux this is disabled by default for known issues with "free" drivers +pref("layers.acceleration.enabled", false); +#else +pref("layers.acceleration.enabled", true); +#endif +// Whether to force acceleration on, ignoring blacklists. +// This requires layers.acceleration.enabled to be set to true +pref("layers.acceleration.force", false); + // Preference that when switched at runtime will run a series of benchmarks // and output the result to stderr. pref("layers.bench.enabled", false); @@ -4506,18 +4515,6 @@ pref("layers.bench.enabled", false); pref("layers.gpu-process.dev.enabled", true); #endif -// Whether to force acceleration on, ignoring blacklists. -#ifdef ANDROID -// bug 838603 -- on Android, accidentally blacklisting OpenGL layers -// means a startup crash for everyone. -// Temporarily force-enable GL compositing. This is default-disabled -// deep within the bowels of the widgetry system. Remove me when GL -// compositing isn't default disabled in widget/android. -pref("layers.acceleration.force-enabled", true); -#else -pref("layers.acceleration.force-enabled", false); -#endif - pref("layers.acceleration.draw-fps", false); // Enable DEAA antialiasing for transformed layers in the compositor -- cgit v1.2.3 From 90773547e74b5c03a5bb60b9c156f987c73b3dcc Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Sun, 26 Jan 2020 10:28:17 +0100 Subject: Issue #1360 - Part 2: Update tests for changed preferences. --- layout/base/crashtests/crashtests.list | 2 +- layout/tools/reftest/reftestcommandline.py | 3 ++- layout/tools/reftest/runreftest.py | 5 ----- testing/mochitest/runtests.py | 5 ----- testing/mozharness/configs/unittests/linux_unittest.py | 3 ++- testing/mozharness/configs/unittests/win_taskcluster_unittest.py | 2 +- testing/mozharness/configs/unittests/win_unittest.py | 2 +- testing/talos/talos/test.py | 4 ++-- testing/talos/talos/ttest.py | 2 +- testing/testsuite-targets.mk | 4 ++-- testing/web-platform/harness/wptrunner/browsers/firefox.py | 5 ----- 11 files changed, 12 insertions(+), 25 deletions(-) diff --git a/layout/base/crashtests/crashtests.list b/layout/base/crashtests/crashtests.list index e2cb99e04..6ded4ff3f 100644 --- a/layout/base/crashtests/crashtests.list +++ b/layout/base/crashtests/crashtests.list @@ -448,7 +448,7 @@ load 876092.html load 876221.html load 897852.html asserts(4-6) asserts-if(Android&&!asyncPan,2) load 898913.html # bug 847368 -pref(layers.acceleration.disabled,true) pref(layers.force-active,true) load 919434.html +pref(layers.acceleration.enabled,false) pref(layers.force-active,true) load 919434.html load 926728.html load 930381.html load 931450.html diff --git a/layout/tools/reftest/reftestcommandline.py b/layout/tools/reftest/reftestcommandline.py index da76fbd9a..f983be528 100644 --- a/layout/tools/reftest/reftestcommandline.py +++ b/layout/tools/reftest/reftestcommandline.py @@ -323,7 +323,8 @@ class DesktopArgumentsParser(ReftestArgumentsParser): def _prefs_gpu(self): if mozinfo.os != "win": - return ["layers.acceleration.force-enabled=true"] + return ["layers.acceleration.enabled=true", + "layers.acceleration.force=true"] return [] def validate(self, options, reftest): diff --git a/layout/tools/reftest/runreftest.py b/layout/tools/reftest/runreftest.py index 7845903bd..7061b16ca 100644 --- a/layout/tools/reftest/runreftest.py +++ b/layout/tools/reftest/runreftest.py @@ -287,11 +287,6 @@ class RefTest(object): prefs['browser.tabs.remote.autostart'] = True prefs['extensions.e10sBlocksEnabling'] = False - # Bug 1262954: For winXP + e10s disable acceleration - if platform.system() in ("Windows", "Microsoft") and \ - '5.1' in platform.version() and options.e10s: - prefs['layers.acceleration.disabled'] = True - # Bug 1300355: Disable canvas cache for win7 as it uses # too much memory and causes OOMs. if platform.system() in ("Windows", "Microsoft") and \ diff --git a/testing/mochitest/runtests.py b/testing/mochitest/runtests.py index dd5439bd1..6763952af 100644 --- a/testing/mochitest/runtests.py +++ b/testing/mochitest/runtests.py @@ -1678,11 +1678,6 @@ toolbar#nav-bar { prefs.update(self.extraPrefs(options.extraPrefs)) - # Bug 1262954: For windows XP + e10s disable acceleration - if platform.system() in ("Windows", "Microsoft") and \ - '5.1' in platform.version() and options.e10s: - prefs['layers.acceleration.disabled'] = True - # interpolate preferences interpolation = { "server": "%s:%s" % diff --git a/testing/mozharness/configs/unittests/linux_unittest.py b/testing/mozharness/configs/unittests/linux_unittest.py index 77e4ed501..b591fa559 100644 --- a/testing/mozharness/configs/unittests/linux_unittest.py +++ b/testing/mozharness/configs/unittests/linux_unittest.py @@ -222,7 +222,8 @@ config = { }, "reftest-no-accel": { "options": ["--suite=reftest", - "--setpref=layers.acceleration.force-enabled=disabled"], + "--setpref=layers.acceleration.enabled=disabled", + "--setpref=layers.acceleration.force=disabled"], "tests": ["tests/reftest/tests/layout/reftests/reftest.list"]}, }, "all_xpcshell_suites": { diff --git a/testing/mozharness/configs/unittests/win_taskcluster_unittest.py b/testing/mozharness/configs/unittests/win_taskcluster_unittest.py index 161e8e65e..2eeae22e2 100644 --- a/testing/mozharness/configs/unittests/win_taskcluster_unittest.py +++ b/testing/mozharness/configs/unittests/win_taskcluster_unittest.py @@ -204,7 +204,7 @@ config = { "reftest-no-accel": { "options": ["--suite=reftest", "--setpref=gfx.direct2d.disabled=true", - "--setpref=layers.acceleration.disabled=true"], + "--setpref=layers.acceleration.enabled=false"], "tests": ["tests/reftest/tests/layout/reftests/reftest.list"] }, }, diff --git a/testing/mozharness/configs/unittests/win_unittest.py b/testing/mozharness/configs/unittests/win_unittest.py index caa2978c6..1f682cc8f 100644 --- a/testing/mozharness/configs/unittests/win_unittest.py +++ b/testing/mozharness/configs/unittests/win_unittest.py @@ -204,7 +204,7 @@ config = { "reftest-no-accel": { "options": ["--suite=reftest", "--setpref=gfx.direct2d.disabled=true", - "--setpref=layers.acceleration.disabled=true"], + "--setpref=layers.acceleration.enabled=false"], "tests": ["tests/reftest/tests/layout/reftests/reftest.list"] }, }, diff --git a/testing/talos/talos/test.py b/testing/talos/talos/test.py index dc1306b8e..6df5835bb 100644 --- a/testing/talos/talos/test.py +++ b/testing/talos/talos/test.py @@ -556,8 +556,8 @@ class basic_compositor_video(PageloaderTest): sps_profile_interval = 1 sps_profile_entries = 2000000 preferences = {'full-screen-api.allow-trusted-requests-only': False, - 'layers.acceleration.force-enabled': False, - 'layers.acceleration.disabled': True, + 'layers.acceleration.force': False, + 'layers.acceleration.enabled': False, 'layout.frame_rate': 0, 'docshell.event_starvation_delay_hint': 1, 'full-screen-api.warning.timeout': 500, diff --git a/testing/talos/talos/ttest.py b/testing/talos/talos/ttest.py index 4a0fcd135..3c57f020d 100644 --- a/testing/talos/talos/ttest.py +++ b/testing/talos/talos/ttest.py @@ -64,7 +64,7 @@ class TTest(object): # Bug 1262954: winxp + e10s, disable hwaccel if self.platform_type == "win_" and browser_config['e10s']: prefs = browser_config['preferences'] - prefs['layers.acceleration.disabled'] = True + prefs['layers.acceleration.enabled'] = False with FFSetup(browser_config, test_config) as setup: return self._runTest(browser_config, test_config, setup) diff --git a/testing/testsuite-targets.mk b/testing/testsuite-targets.mk index ebe0d06cf..f10bd079c 100644 --- a/testing/testsuite-targets.mk +++ b/testing/testsuite-targets.mk @@ -60,11 +60,11 @@ RUN_REFTEST_B2G = rm -f ./$@.log && $(PYTHON) _tests/reftest/runreftestb2g.py \ ifeq ($(OS_ARCH),WINNT) #{ # GPU-rendered shadow layers are unsupported here -OOP_CONTENT = --setpref=layers.async-pan-zoom.enabled=true --setpref=browser.tabs.remote.autostart=true --setpref=layers.acceleration.disabled=true +OOP_CONTENT = --setpref=layers.async-pan-zoom.enabled=true --setpref=browser.tabs.remote.autostart=true --setpref=layers.acceleration.enabled=false GPU_RENDERING = else OOP_CONTENT = --setpref=layers.async-pan-zoom.enabled=true --setpref=browser.tabs.remote.autostart=true -GPU_RENDERING = --setpref=layers.acceleration.force-enabled=true +GPU_RENDERING = --setpref=layers.acceleration.enabled=true --setpref=layers.acceleration.force=true endif #} reftest: TEST_PATH?=layout/reftests/reftest.list diff --git a/testing/web-platform/harness/wptrunner/browsers/firefox.py b/testing/web-platform/harness/wptrunner/browsers/firefox.py index 183820c5c..c03dd0eda 100644 --- a/testing/web-platform/harness/wptrunner/browsers/firefox.py +++ b/testing/web-platform/harness/wptrunner/browsers/firefox.py @@ -142,11 +142,6 @@ class FirefoxBrowser(Browser): if self.e10s: self.profile.set_preferences({"browser.tabs.remote.autostart": True}) - # Bug 1262954: winxp + e10s, disable hwaccel - if (self.e10s and platform.system() in ("Windows", "Microsoft") and - '5.1' in platform.version()): - self.profile.set_preferences({"layers.acceleration.disabled": True}) - if self.ca_certificate_path is not None: self.setup_ssl() -- cgit v1.2.3 From a2b56b295b8bd089b74c5d93148edafe7e6da912 Mon Sep 17 00:00:00 2001 From: Gaming4JC Date: Wed, 1 Jan 2020 14:56:19 -0500 Subject: Bug 1276438 part 1. Move the implementation of the .body getter from nsHTMLDocument to nsIDocument. Tag UXP Issue #1344 Tag UXP Issue #252 --- dom/base/nsDocument.cpp | 20 ++++++++++++++++++++ dom/base/nsIDocument.h | 4 ++++ dom/html/nsHTMLDocument.cpp | 20 -------------------- dom/html/nsHTMLDocument.h | 2 +- 4 files changed, 25 insertions(+), 21 deletions(-) diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp index afe88a454..83c2e5bb7 100644 --- a/dom/base/nsDocument.cpp +++ b/dom/base/nsDocument.cpp @@ -6536,6 +6536,26 @@ nsIDocument::GetHtmlChildElement(nsIAtom* aTag) return nullptr; } +nsGenericHTMLElement* +nsIDocument::GetBody() +{ + Element* html = GetHtmlElement(); + if (!html) { + return nullptr; + } + + for (nsIContent* child = html->GetFirstChild(); + child; + child = child->GetNextSibling()) { + if (child->IsHTMLElement(nsGkAtoms::body) || + child->IsHTMLElement(nsGkAtoms::frameset)) { + return static_cast(child); + } + } + + return nullptr; +} + Element* nsDocument::GetTitleElement() { diff --git a/dom/base/nsIDocument.h b/dom/base/nsIDocument.h index fdaee39ca..b3879c624 100644 --- a/dom/base/nsIDocument.h +++ b/dom/base/nsIDocument.h @@ -61,6 +61,7 @@ class nsFrameLoader; class nsHTMLCSSStyleSheet; class nsHTMLDocument; class nsHTMLStyleSheet; +class nsGenericHTMLElement; class nsIAtom; class nsIBFCacheEntry; class nsIChannel; @@ -1036,6 +1037,9 @@ public: Element* GetHeadElement() { return GetHtmlChildElement(nsGkAtoms::head); } + // Get the "body" in the sense of document.body: The first or + // that's a child of a root + nsGenericHTMLElement* GetBody(); /** * Accessors to the collection of stylesheets owned by this document. diff --git a/dom/html/nsHTMLDocument.cpp b/dom/html/nsHTMLDocument.cpp index 0f2d90673..23c73298d 100644 --- a/dom/html/nsHTMLDocument.cpp +++ b/dom/html/nsHTMLDocument.cpp @@ -1013,26 +1013,6 @@ nsHTMLDocument::SetDomain(const nsAString& aDomain, ErrorResult& rv) rv = NodePrincipal()->SetDomain(newURI); } -nsGenericHTMLElement* -nsHTMLDocument::GetBody() -{ - Element* html = GetHtmlElement(); - if (!html) { - return nullptr; - } - - for (nsIContent* child = html->GetFirstChild(); - child; - child = child->GetNextSibling()) { - if (child->IsHTMLElement(nsGkAtoms::body) || - child->IsHTMLElement(nsGkAtoms::frameset)) { - return static_cast(child); - } - } - - return nullptr; -} - NS_IMETHODIMP nsHTMLDocument::GetBody(nsIDOMHTMLElement** aBody) { diff --git a/dom/html/nsHTMLDocument.h b/dom/html/nsHTMLDocument.h index 1fa81f6cd..02fc22d42 100644 --- a/dom/html/nsHTMLDocument.h +++ b/dom/html/nsHTMLDocument.h @@ -175,7 +175,7 @@ public: JS::MutableHandle aRetval, mozilla::ErrorResult& rv); void GetSupportedNames(nsTArray& aNames); - nsGenericHTMLElement *GetBody(); + using nsIDocument::GetBody; void SetBody(nsGenericHTMLElement* aBody, mozilla::ErrorResult& rv); mozilla::dom::HTMLSharedElement *GetHead() { return static_cast(GetHeadElement()); -- cgit v1.2.3 From 32f3f8826f396fd17c1c77770d073d0abf15c904 Mon Sep 17 00:00:00 2001 From: Gaming4JC Date: Wed, 1 Jan 2020 15:04:58 -0500 Subject: Bug 1276438 part 2. Move the implementation of the .body setter from nsHTMLDocument to nsIDocument. Tag UXP Issue #1344 Tag UXP Issue #252 --- dom/base/nsDocument.cpp | 25 +++++++++++++++++++++++++ dom/base/nsIDocument.h | 2 ++ dom/html/nsHTMLDocument.cpp | 25 ------------------------- dom/html/nsHTMLDocument.h | 2 +- 4 files changed, 28 insertions(+), 26 deletions(-) diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp index 83c2e5bb7..69cbff16c 100644 --- a/dom/base/nsDocument.cpp +++ b/dom/base/nsDocument.cpp @@ -6556,6 +6556,31 @@ nsIDocument::GetBody() return nullptr; } +void +nsIDocument::SetBody(nsGenericHTMLElement* newBody, ErrorResult& rv) +{ + nsCOMPtr root = GetRootElement(); + + // The body element must be either a body tag or a frameset tag. And we must + // have a html root tag, otherwise GetBody will not return the newly set + // body. + if (!newBody || + !newBody->IsAnyOfHTMLElements(nsGkAtoms::body, nsGkAtoms::frameset) || + !root || !root->IsHTMLElement() || + !root->IsHTMLElement(nsGkAtoms::html)) { + rv.Throw(NS_ERROR_DOM_HIERARCHY_REQUEST_ERR); + return; + } + + // Use DOM methods so that we pass through the appropriate security checks. + nsCOMPtr currentBody = GetBodyElement(); + if (currentBody) { + root->ReplaceChild(*newBody, *currentBody, rv); + } else { + root->AppendChild(*newBody, rv); + } +} + Element* nsDocument::GetTitleElement() { diff --git a/dom/base/nsIDocument.h b/dom/base/nsIDocument.h index b3879c624..e44ab047e 100644 --- a/dom/base/nsIDocument.h +++ b/dom/base/nsIDocument.h @@ -1040,6 +1040,8 @@ public: // Get the "body" in the sense of document.body: The first or // that's a child of a root nsGenericHTMLElement* GetBody(); + // Set the "body" in the sense of document.body. + void SetBody(nsGenericHTMLElement* aBody, mozilla::ErrorResult& rv); /** * Accessors to the collection of stylesheets owned by this document. diff --git a/dom/html/nsHTMLDocument.cpp b/dom/html/nsHTMLDocument.cpp index 23c73298d..1eeef737a 100644 --- a/dom/html/nsHTMLDocument.cpp +++ b/dom/html/nsHTMLDocument.cpp @@ -1034,31 +1034,6 @@ nsHTMLDocument::SetBody(nsIDOMHTMLElement* aBody) return rv.StealNSResult(); } -void -nsHTMLDocument::SetBody(nsGenericHTMLElement* newBody, ErrorResult& rv) -{ - nsCOMPtr root = GetRootElement(); - - // The body element must be either a body tag or a frameset tag. And we must - // have a html root tag, otherwise GetBody will not return the newly set - // body. - if (!newBody || - !newBody->IsAnyOfHTMLElements(nsGkAtoms::body, nsGkAtoms::frameset) || - !root || !root->IsHTMLElement() || - !root->IsHTMLElement(nsGkAtoms::html)) { - rv.Throw(NS_ERROR_DOM_HIERARCHY_REQUEST_ERR); - return; - } - - // Use DOM methods so that we pass through the appropriate security checks. - nsCOMPtr currentBody = GetBodyElement(); - if (currentBody) { - root->ReplaceChild(*newBody, *currentBody, rv); - } else { - root->AppendChild(*newBody, rv); - } -} - NS_IMETHODIMP nsHTMLDocument::GetHead(nsIDOMHTMLHeadElement** aHead) { diff --git a/dom/html/nsHTMLDocument.h b/dom/html/nsHTMLDocument.h index 02fc22d42..c9e46b3fa 100644 --- a/dom/html/nsHTMLDocument.h +++ b/dom/html/nsHTMLDocument.h @@ -176,7 +176,7 @@ public: mozilla::ErrorResult& rv); void GetSupportedNames(nsTArray& aNames); using nsIDocument::GetBody; - void SetBody(nsGenericHTMLElement* aBody, mozilla::ErrorResult& rv); + using nsIDocument::SetBody; mozilla::dom::HTMLSharedElement *GetHead() { return static_cast(GetHeadElement()); } -- cgit v1.2.3 From ce285b6f2d48ce945b194fd7982cd6a5a306e939 Mon Sep 17 00:00:00 2001 From: Gaming4JC Date: Wed, 1 Jan 2020 15:08:37 -0500 Subject: Bug 1276438 part 3. Align the .body setter with the spec a bit better. There are two changes here: 1) We allow setting .body even if the root element is not an . This is what the spec says to do, and what we used to do before the changes in bug 366200. No tests for this yet, pending https://github.com/whatwg/html/issues/3403 getting resolved. 2) We use GetBody(), not GetBodyElement(), to look for an existing thing to replace. This matters if there are s involved. Tag UXP Issue #1344 Tag UXP Issue #252 --- dom/base/nsDocument.cpp | 8 ++-- .../dom-tree-accessors/Document.body.html | 50 ++++++++++++++++++++++ 2 files changed, 53 insertions(+), 5 deletions(-) diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp index 69cbff16c..3faa39ab3 100644 --- a/dom/base/nsDocument.cpp +++ b/dom/base/nsDocument.cpp @@ -6562,18 +6562,16 @@ nsIDocument::SetBody(nsGenericHTMLElement* newBody, ErrorResult& rv) nsCOMPtr root = GetRootElement(); // The body element must be either a body tag or a frameset tag. And we must - // have a html root tag, otherwise GetBody will not return the newly set - // body. + // have a root element to be able to add kids to it. if (!newBody || !newBody->IsAnyOfHTMLElements(nsGkAtoms::body, nsGkAtoms::frameset) || - !root || !root->IsHTMLElement() || - !root->IsHTMLElement(nsGkAtoms::html)) { + !root) { rv.Throw(NS_ERROR_DOM_HIERARCHY_REQUEST_ERR); return; } // Use DOM methods so that we pass through the appropriate security checks. - nsCOMPtr currentBody = GetBodyElement(); + nsCOMPtr currentBody = GetBody(); if (currentBody) { root->ReplaceChild(*newBody, *currentBody, rv); } else { diff --git a/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/Document.body.html b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/Document.body.html index 07f1edf93..7d8548885 100644 --- a/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/Document.body.html +++ b/testing/web-platform/tests/html/dom/documents/dom-tree-accessors/Document.body.html @@ -166,4 +166,54 @@ test(function() { doc.body = new_frameset; assert_equals(doc.body, new_frameset, "test6-3, append frameset to a new document"); }, "Setting document.body to a new frameset element."); + +test(function() { + var doc = createDocument(); + var html = doc.appendChild(doc.createElement("html")); + var f = + html.appendChild(doc.createElement("frameset")); + assert_equals(doc.body, f); + + var b = doc.createElement("body"); + doc.body = b; + + assert_equals(f.parentNode, null, + "Frameset should have been removed from the tree"); + assert_equals(doc.body, b, "Body should be the new doc.body"); +}, "Setting document.body to a body will replace an existing frameset if there is one."); + +test(function() { + var doc = createDocument(); + var html = doc.appendChild(doc.createElement("html")); + var b = + html.appendChild(doc.createElement("body")); + assert_equals(doc.body, b); + + var f = doc.createElement("frameset"); + doc.body = f; + + assert_equals(b.parentNode, null, + "Body should have been removed from the tree"); + assert_equals(doc.body, f, "Frameset should be the new doc.body"); +}, "Setting document.body to a frameset will replace an existing body if there is one."); + +test(function() { + var doc = createDocument(); + var html = doc.appendChild(doc.createElement("html")); + var b = + html.appendChild(doc.createElement("body")); + var f1 = html.appendChild(doc.createElement("frameset")); + assert_equals(doc.body, b); + + var f2 = doc.createElement("frameset"); + doc.body = f2; + + assert_equals(b.parentNode, null, + "Body should have been removed from the tree"); + assert_equals(f1.parentNode, html, + "Frameset following body should still be in the tree."); + assert_equals(doc.body, f2, "New frameset should be the new doc.body"); + assert_equals(f2.nextSibling, f1, "New frameset should have replaced the body"); +}, "Setting document.body to a frameset will replace the first existing body/frameset."); + -- cgit v1.2.3 From bc8543bf793b5c203600c57565214b5e20f54592 Mon Sep 17 00:00:00 2001 From: Gaming4JC Date: Tue, 7 Jan 2020 20:27:27 -0500 Subject: Bug 1271549 - Remove details and summary preference. Tag UXP Issue #1344 --- dom/html/HTMLDetailsElement.cpp | 30 +--------------------- dom/html/HTMLDetailsElement.h | 2 -- dom/html/HTMLSummaryElement.cpp | 12 +-------- dom/webidl/EventHandler.webidl | 1 - dom/webidl/HTMLDetailsElement.webidl | 1 - layout/base/nsCSSFrameConstructor.cpp | 8 ++---- layout/generic/crashtests/crashtests.list | 16 ++++++------ layout/generic/nsContainerFrame.cpp | 10 +++----- .../details-summary/disabled-no-summary-ref.html | 11 -------- .../disabled-single-summary-ref.html | 12 --------- layout/reftests/details-summary/reftest-stylo.list | 6 ----- layout/reftests/details-summary/reftest.list | 7 ----- layout/style/nsLayoutStylesheetCache.cpp | 10 ++------ modules/libpref/init/all.js | 3 --- .../web-platform/meta/html/dom/interfaces.html.ini | 2 +- .../meta/html/dom/reflection-misc.html.ini | 2 +- .../the-details-element/details.html.ini | 3 --- .../the-details-element/toggleEvent.html.ini | 3 --- .../meta/html/semantics/interfaces.html.ini | 2 +- testing/web-platform/meta/svg/interfaces.html.ini | 1 - 20 files changed, 21 insertions(+), 121 deletions(-) delete mode 100644 layout/reftests/details-summary/disabled-no-summary-ref.html delete mode 100644 layout/reftests/details-summary/disabled-single-summary-ref.html delete mode 100644 testing/web-platform/meta/html/semantics/interactive-elements/the-details-element/details.html.ini delete mode 100644 testing/web-platform/meta/html/semantics/interactive-elements/the-details-element/toggleEvent.html.ini diff --git a/dom/html/HTMLDetailsElement.cpp b/dom/html/HTMLDetailsElement.cpp index ed20b50ca..8619b1450 100644 --- a/dom/html/HTMLDetailsElement.cpp +++ b/dom/html/HTMLDetailsElement.cpp @@ -6,39 +6,11 @@ #include "mozilla/dom/HTMLDetailsElement.h" #include "mozilla/dom/HTMLDetailsElementBinding.h" -#include "mozilla/dom/HTMLUnknownElement.h" -#include "mozilla/Preferences.h" - -// Expand NS_IMPL_NS_NEW_HTML_ELEMENT(Details) to add pref check. -nsGenericHTMLElement* -NS_NewHTMLDetailsElement(already_AddRefed&& aNodeInfo, - mozilla::dom::FromParser aFromParser) -{ - if (!mozilla::dom::HTMLDetailsElement::IsDetailsEnabled()) { - return new mozilla::dom::HTMLUnknownElement(aNodeInfo); - } - - return new mozilla::dom::HTMLDetailsElement(aNodeInfo); -} +NS_IMPL_NS_NEW_HTML_ELEMENT(Details) namespace mozilla { namespace dom { -/* static */ bool -HTMLDetailsElement::IsDetailsEnabled() -{ - static bool isDetailsEnabled = false; - static bool added = false; - - if (!added) { - Preferences::AddBoolVarCache(&isDetailsEnabled, - "dom.details_element.enabled"); - added = true; - } - - return isDetailsEnabled; -} - HTMLDetailsElement::~HTMLDetailsElement() { } diff --git a/dom/html/HTMLDetailsElement.h b/dom/html/HTMLDetailsElement.h index 5a3af27b4..6adf567bf 100644 --- a/dom/html/HTMLDetailsElement.h +++ b/dom/html/HTMLDetailsElement.h @@ -23,8 +23,6 @@ class HTMLDetailsElement final : public nsGenericHTMLElement public: using NodeInfo = mozilla::dom::NodeInfo; - static bool IsDetailsEnabled(); - explicit HTMLDetailsElement(already_AddRefed& aNodeInfo) : nsGenericHTMLElement(aNodeInfo) { diff --git a/dom/html/HTMLSummaryElement.cpp b/dom/html/HTMLSummaryElement.cpp index ee3c07b20..42ead6b87 100644 --- a/dom/html/HTMLSummaryElement.cpp +++ b/dom/html/HTMLSummaryElement.cpp @@ -14,17 +14,7 @@ #include "mozilla/TextEvents.h" #include "nsFocusManager.h" -// Expand NS_IMPL_NS_NEW_HTML_ELEMENT(Summary) to add pref check. -nsGenericHTMLElement* -NS_NewHTMLSummaryElement(already_AddRefed&& aNodeInfo, - mozilla::dom::FromParser aFromParser) -{ - if (!mozilla::dom::HTMLDetailsElement::IsDetailsEnabled()) { - return new mozilla::dom::HTMLUnknownElement(aNodeInfo); - } - - return new mozilla::dom::HTMLSummaryElement(aNodeInfo); -} +NS_IMPL_NS_NEW_HTML_ELEMENT(Summary) namespace mozilla { namespace dom { diff --git a/dom/webidl/EventHandler.webidl b/dom/webidl/EventHandler.webidl index b92e3a2bb..484a8e95c 100644 --- a/dom/webidl/EventHandler.webidl +++ b/dom/webidl/EventHandler.webidl @@ -94,7 +94,6 @@ interface GlobalEventHandlers { [Pref="dom.select_events.enabled"] attribute EventHandler onselectstart; - [Pref="dom.details_element.enabled"] attribute EventHandler ontoggle; // Pointer events handlers diff --git a/dom/webidl/HTMLDetailsElement.webidl b/dom/webidl/HTMLDetailsElement.webidl index 133ecf125..104606eb1 100644 --- a/dom/webidl/HTMLDetailsElement.webidl +++ b/dom/webidl/HTMLDetailsElement.webidl @@ -11,7 +11,6 @@ * and create derivative works of this document. */ -[Pref="dom.details_element.enabled"] interface HTMLDetailsElement : HTMLElement { [SetterThrows] attribute boolean open; diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index ec676ca92..34cfc6b59 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -3563,10 +3563,6 @@ nsCSSFrameConstructor::FindHTMLData(Element* aElement, return nullptr; } - if (aTag == nsGkAtoms::details && !HTMLDetailsElement::IsDetailsEnabled()) { - return nullptr; - } - static const FrameConstructionDataByTag sHTMLData[] = { SIMPLE_TAG_CHAIN(img, nsCSSFrameConstructor::FindImgData), SIMPLE_TAG_CHAIN(mozgeneratedcontentimage, @@ -5788,7 +5784,7 @@ nsCSSFrameConstructor::AddFrameConstructionItemsInternal(nsFrameConstructorState // ::before and ::after); we always want to create "internal" anonymous // content. auto* details = HTMLDetailsElement::FromContentOrNull(parent); - if (details && details->IsDetailsEnabled() && !details->Open() && + if (details && !details->Open() && (!aContent->IsRootOfNativeAnonymousSubtree() || aContent->IsGeneratedContentContainerForBefore() || aContent->IsGeneratedContentContainerForAfter())) { @@ -5956,7 +5952,7 @@ nsCSSFrameConstructor::AddFrameConstructionItemsInternal(nsFrameConstructorState } FrameConstructionItem* item = nullptr; - if (details && details->IsDetailsEnabled() && details->Open()) { + if (details && details->Open()) { auto* summary = HTMLSummaryElement::FromContentOrNull(aContent); if (summary && summary->IsMainSummary()) { // If details is open, the main summary needs to be rendered as if it is diff --git a/layout/generic/crashtests/crashtests.list b/layout/generic/crashtests/crashtests.list index 183556ab9..a3c0d62c6 100644 --- a/layout/generic/crashtests/crashtests.list +++ b/layout/generic/crashtests/crashtests.list @@ -606,19 +606,19 @@ pref(layout.css.grid.enabled,true) load 1225376.html pref(layout.css.grid.enabled,true) load 1225592.html load 1229437-1.html load 1229437-2.html -pref(dom.details_element.enabled,true) load details-containing-only-text.html -pref(dom.details_element.enabled,true) load details-display-none-summary-1.html -pref(dom.details_element.enabled,true) load details-display-none-summary-2.html -pref(dom.details_element.enabled,true) load details-display-none-summary-3.html -pref(dom.details_element.enabled,true) load details-open-overflow-auto.html -pref(dom.details_element.enabled,true) load details-open-overflow-hidden.html -pref(dom.details_element.enabled,true) load details-three-columns.html +load details-containing-only-text.html +load details-display-none-summary-1.html +load details-display-none-summary-2.html +load details-display-none-summary-3.html +load details-open-overflow-auto.html +load details-open-overflow-hidden.html +load details-three-columns.html load first-letter-638937-1.html load first-letter-638937-2.html load flex-nested-abspos-1.html pref(dom.meta-viewport.enabled,true) test-pref(font.size.inflation.emPerLine,15) asserts(0-100) load font-inflation-762332.html # bug 762332 load outline-on-frameset.xhtml -pref(dom.details_element.enabled,true) load summary-position-out-of-flow.html +load summary-position-out-of-flow.html load text-overflow-bug666751-1.html load text-overflow-bug666751-2.html load text-overflow-bug670564.xhtml diff --git a/layout/generic/nsContainerFrame.cpp b/layout/generic/nsContainerFrame.cpp index abf687c9b..afc4ed96f 100644 --- a/layout/generic/nsContainerFrame.cpp +++ b/layout/generic/nsContainerFrame.cpp @@ -1890,12 +1890,10 @@ nsContainerFrame::RenumberFrameAndDescendants(int32_t* aOrdinal, } // Do not renumber list for summary elements. - if (HTMLDetailsElement::IsDetailsEnabled()) { - HTMLSummaryElement* summary = - HTMLSummaryElement::FromContent(kid->GetContent()); - if (summary && summary->IsMainSummary()) { - return false; - } + HTMLSummaryElement* summary = + HTMLSummaryElement::FromContent(kid->GetContent()); + if (summary && summary->IsMainSummary()) { + return false; } bool kidRenumberedABullet = false; diff --git a/layout/reftests/details-summary/disabled-no-summary-ref.html b/layout/reftests/details-summary/disabled-no-summary-ref.html deleted file mode 100644 index 6ecdbcdc0..000000000 --- a/layout/reftests/details-summary/disabled-no-summary-ref.html +++ /dev/null @@ -1,11 +0,0 @@ - - - - - -
-

This is the details.

-
- - diff --git a/layout/reftests/details-summary/disabled-single-summary-ref.html b/layout/reftests/details-summary/disabled-single-summary-ref.html deleted file mode 100644 index f643af6dc..000000000 --- a/layout/reftests/details-summary/disabled-single-summary-ref.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - -
-
Summary
-

This is the details.

-
- - diff --git a/layout/reftests/details-summary/reftest-stylo.list b/layout/reftests/details-summary/reftest-stylo.list index e23b1206b..2c6ec0d7b 100644 --- a/layout/reftests/details-summary/reftest-stylo.list +++ b/layout/reftests/details-summary/reftest-stylo.list @@ -1,10 +1,4 @@ # DO NOT EDIT! This is a auto-generated temporary list for Stylo testing -default-preferences pref(dom.details_element.enabled,true) - -# Disable
and -pref(dom.details_element.enabled,false) == single-summary.html single-summary.html -pref(dom.details_element.enabled,false) == open-single-summary.html open-single-summary.html -pref(dom.details_element.enabled,false) == no-summary.html no-summary.html # Basic handling == multiple-summary.html multiple-summary.html diff --git a/layout/reftests/details-summary/reftest.list b/layout/reftests/details-summary/reftest.list index 92b1404b5..e96581ad4 100644 --- a/layout/reftests/details-summary/reftest.list +++ b/layout/reftests/details-summary/reftest.list @@ -1,10 +1,3 @@ -default-preferences pref(dom.details_element.enabled,true) - -# Disable
and -pref(dom.details_element.enabled,false) == single-summary.html disabled-single-summary-ref.html -pref(dom.details_element.enabled,false) == open-single-summary.html disabled-single-summary-ref.html -pref(dom.details_element.enabled,false) == no-summary.html disabled-no-summary-ref.html - # Basic handling == multiple-summary.html single-summary.html == open-multiple-summary.html open-multiple-summary-ref.html diff --git a/layout/style/nsLayoutStylesheetCache.cpp b/layout/style/nsLayoutStylesheetCache.cpp index e8c6d09d7..0e6bc35ee 100644 --- a/layout/style/nsLayoutStylesheetCache.cpp +++ b/layout/style/nsLayoutStylesheetCache.cpp @@ -122,11 +122,6 @@ nsLayoutStylesheetCache::UASheet() StyleSheet* nsLayoutStylesheetCache::HTMLSheet() { - if (!mHTMLSheet) { - LoadSheetURL("resource://gre-resources/html.css", - &mHTMLSheet, eAgentSheetFeatures, eCrash); - } - return mHTMLSheet; } @@ -322,6 +317,8 @@ nsLayoutStylesheetCache::nsLayoutStylesheetCache(StyleBackendType aType) // per-profile, since they're profile-invariant. LoadSheetURL("resource://gre-resources/counterstyles.css", &mCounterStylesSheet, eAgentSheetFeatures, eCrash); + LoadSheetURL("resource://gre-resources/html.css", + &mHTMLSheet, eAgentSheetFeatures, eCrash); LoadSheetURL("chrome://global/content/minimal-xul.css", &mMinimalXULSheet, eAgentSheetFeatures, eCrash); LoadSheetURL("resource://gre-resources/quirk.css", @@ -382,8 +379,6 @@ nsLayoutStylesheetCache::For(StyleBackendType aType) // "layout.css.example-pref.enabled"); Preferences::RegisterCallback(&DependentPrefChanged, "layout.css.grid.enabled"); - Preferences::RegisterCallback(&DependentPrefChanged, - "dom.details_element.enabled"); } return cache; @@ -555,7 +550,6 @@ nsLayoutStylesheetCache::DependentPrefChanged(const char* aPref, void* aData) gStyleCache_Servo ? &gStyleCache_Servo->sheet_ : nullptr); INVALIDATE(mUASheet); // for layout.css.grid.enabled - INVALIDATE(mHTMLSheet); // for dom.details_element.enabled #undef INVALIDATE } diff --git a/modules/libpref/init/all.js b/modules/libpref/init/all.js index c5daf9213..dacfe6e49 100644 --- a/modules/libpref/init/all.js +++ b/modules/libpref/init/all.js @@ -5328,9 +5328,6 @@ pref("dom.audiochannel.mutedByDefault", false); // HTML element pref("dom.dialog_element.enabled", false); -// Enable
and tags. -pref("dom.details_element.enabled", true); - // Secure Element API #ifdef MOZ_SECUREELEMENT pref("dom.secureelement.enabled", false); diff --git a/testing/web-platform/meta/html/dom/interfaces.html.ini b/testing/web-platform/meta/html/dom/interfaces.html.ini index 16a03337e..db6a464d0 100644 --- a/testing/web-platform/meta/html/dom/interfaces.html.ini +++ b/testing/web-platform/meta/html/dom/interfaces.html.ini @@ -1,6 +1,6 @@ [interfaces.html] type: testharness - prefs: [dom.forms.inputmode:true, dom.details_element.enabled:true, dom.dialog_element.enabled:true] + prefs: [dom.forms.inputmode:true, dom.dialog_element.enabled:true] [Document interface: attribute domain] expected: FAIL diff --git a/testing/web-platform/meta/html/dom/reflection-misc.html.ini b/testing/web-platform/meta/html/dom/reflection-misc.html.ini index b0909cc6d..bc65d4191 100644 --- a/testing/web-platform/meta/html/dom/reflection-misc.html.ini +++ b/testing/web-platform/meta/html/dom/reflection-misc.html.ini @@ -1,6 +1,6 @@ [reflection-misc.html] type: testharness - prefs: [dom.details_element.enabled: true, dom.dialog_element.enabled: true] + prefs: [dom.dialog_element.enabled: true] [html.tabIndex: setAttribute() to object "3" followed by getAttribute()] expected: FAIL diff --git a/testing/web-platform/meta/html/semantics/interactive-elements/the-details-element/details.html.ini b/testing/web-platform/meta/html/semantics/interactive-elements/the-details-element/details.html.ini deleted file mode 100644 index 6ffca742c..000000000 --- a/testing/web-platform/meta/html/semantics/interactive-elements/the-details-element/details.html.ini +++ /dev/null @@ -1,3 +0,0 @@ -[details.html] - type: testharness - prefs: [dom.details_element.enabled:true] diff --git a/testing/web-platform/meta/html/semantics/interactive-elements/the-details-element/toggleEvent.html.ini b/testing/web-platform/meta/html/semantics/interactive-elements/the-details-element/toggleEvent.html.ini deleted file mode 100644 index 335ffd5b3..000000000 --- a/testing/web-platform/meta/html/semantics/interactive-elements/the-details-element/toggleEvent.html.ini +++ /dev/null @@ -1,3 +0,0 @@ -[toggleEvent.html] - type: testharness - prefs: [dom.details_element.enabled:true] diff --git a/testing/web-platform/meta/html/semantics/interfaces.html.ini b/testing/web-platform/meta/html/semantics/interfaces.html.ini index 23f55fbe4..f191cad52 100644 --- a/testing/web-platform/meta/html/semantics/interfaces.html.ini +++ b/testing/web-platform/meta/html/semantics/interfaces.html.ini @@ -1,6 +1,6 @@ [interfaces.html] type: testharness - prefs: [dom.details_element.enabled: true, dom.dialog_element.enabled: true] + prefs: [dom.dialog_element.enabled: true] [Interfaces for image] expected: FAIL diff --git a/testing/web-platform/meta/svg/interfaces.html.ini b/testing/web-platform/meta/svg/interfaces.html.ini index 292ca6b74..410f20f69 100644 --- a/testing/web-platform/meta/svg/interfaces.html.ini +++ b/testing/web-platform/meta/svg/interfaces.html.ini @@ -1,6 +1,5 @@ [interfaces.html] type: testharness - prefs: [dom.details_element.enabled:true] [SVGGeometryElement interface: existence and properties of interface object] expected: FAIL -- cgit v1.2.3 From 2d31ebf6b6bba8c1b90982f687346e5c6a0ff6ef Mon Sep 17 00:00:00 2001 From: Gaming4JC Date: Thu, 2 Jan 2020 21:24:22 -0500 Subject: Bug 1274159 - Part 1: Support looking up definitions by using constructor as a key; Tag UXP Issue #1344 --- dom/base/CustomElementRegistry.cpp | 37 +++++++++++++++++++--- dom/base/CustomElementRegistry.h | 15 ++++++++- dom/bindings/test/test_bug560072.html | 5 +-- .../custom-elements/CustomElementRegistry.html.ini | 3 -- .../custom-element-registry/define.html.ini | 26 --------------- 5 files changed, 50 insertions(+), 36 deletions(-) delete mode 100644 testing/web-platform/meta/custom-elements/custom-element-registry/define.html.ini diff --git a/dom/base/CustomElementRegistry.cpp b/dom/base/CustomElementRegistry.cpp index 3f202d33b..43e4e7e2a 100644 --- a/dom/base/CustomElementRegistry.cpp +++ b/dom/base/CustomElementRegistry.cpp @@ -103,6 +103,7 @@ NS_IMPL_CYCLE_COLLECTION_CLASS(CustomElementRegistry) NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(CustomElementRegistry) tmp->mCustomDefinitions.Clear(); + tmp->mConstructors.clear(); NS_IMPL_CYCLE_COLLECTION_UNLINK(mWhenDefinedPromiseMap) NS_IMPL_CYCLE_COLLECTION_UNLINK(mWindow) NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER @@ -149,6 +150,11 @@ NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(CustomElementRegistry) "mCustomDefinitions prototype", aClosure); } + for (ConstructorMap::Enum iter(tmp->mConstructors); !iter.empty(); iter.popFront()) { + aCallbacks.Trace(&iter.front().mutableKey(), + "mConstructors key", + aClosure); + } NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER NS_IMPL_CYCLE_COLLECTION_TRACE_END @@ -183,6 +189,11 @@ CustomElementRegistry::Create(nsPIDOMWindowInner* aWindow) RefPtr customElementRegistry = new CustomElementRegistry(aWindow); + + if (!customElementRegistry->Init()) { + return nullptr; + } + return customElementRegistry.forget(); } @@ -241,6 +252,12 @@ CustomElementRegistry::~CustomElementRegistry() mozilla::DropJSObjects(this); } +bool +CustomElementRegistry::Init() +{ + return mConstructors.init(); +} + CustomElementDefinition* CustomElementRegistry::LookupCustomElementDefinition(const nsAString& aLocalName, const nsAString* aIs) const @@ -609,9 +626,13 @@ CustomElementRegistry::Define(const nsAString& aName, * 4. If this CustomElementRegistry contains an entry with constructor constructor, * then throw a "NotSupportedError" DOMException and abort these steps. */ - // TODO: Step 3 of HTMLConstructor also needs a way to look up definition by - // using constructor. So I plans to figure out a solution to support both of - // them in bug 1274159. + const auto& ptr = mConstructors.lookup(constructorUnwrapped); + if (ptr) { + MOZ_ASSERT(mCustomDefinitions.Get(ptr->value()), + "Definition must be found in mCustomDefinitions"); + aRv.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR); + return; + } /** * 5. Let localName be name. @@ -767,8 +788,16 @@ CustomElementRegistry::Define(const nsAString& aName, /** * 12. Add definition to this CustomElementRegistry. */ + if (!mConstructors.put(constructorUnwrapped, nameAtom)) { + aRv.Throw(NS_ERROR_FAILURE); + return; + } + mCustomDefinitions.Put(nameAtom, definition); + MOZ_ASSERT(mCustomDefinitions.Count() == mConstructors.count(), + "Number of entries should be the same"); + /** * 13. 14. 15. Upgrade candidates */ @@ -853,4 +882,4 @@ CustomElementDefinition::CustomElementDefinition(nsIAtom* aType, } } // namespace dom -} // namespace mozilla \ No newline at end of file +} // namespace mozilla diff --git a/dom/base/CustomElementRegistry.h b/dom/base/CustomElementRegistry.h index ff803a054..9034dd7ea 100644 --- a/dom/base/CustomElementRegistry.h +++ b/dom/base/CustomElementRegistry.h @@ -7,13 +7,14 @@ #ifndef mozilla_dom_CustomElementRegistry_h #define mozilla_dom_CustomElementRegistry_h +#include "js/GCHashTable.h" #include "js/TypeDecls.h" #include "mozilla/Attributes.h" #include "mozilla/ErrorResult.h" #include "mozilla/dom/BindingDeclarations.h" +#include "mozilla/dom/FunctionBinding.h" #include "nsCycleCollectionParticipant.h" #include "nsWrapperCache.h" -#include "mozilla/dom/FunctionBinding.h" class nsDocument; @@ -173,6 +174,8 @@ private: explicit CustomElementRegistry(nsPIDOMWindowInner* aWindow); ~CustomElementRegistry(); + bool Init(); + /** * Registers an unresolved custom element that is a candidate for * upgrade when the definition is registered via registerElement. @@ -192,15 +195,25 @@ private: DefinitionMap; typedef nsClassHashtable> CandidateMap; + typedef JS::GCHashMap, + nsCOMPtr, + js::MovableCellHasher>, + js::SystemAllocPolicy> ConstructorMap; // Hashtable for custom element definitions in web components. // Custom prototypes are stored in the compartment where // registerElement was called. DefinitionMap mCustomDefinitions; + // Hashtable for looking up definitions by using constructor as key. + // Custom elements' name are stored here and we need to lookup + // mCustomDefinitions again to get definitions. + ConstructorMap mConstructors; + typedef nsRefPtrHashtable WhenDefinedPromiseMap; WhenDefinedPromiseMap mWhenDefinedPromiseMap; + // The "upgrade candidates map" from the web components spec. Maps from a // namespace id and local name to a list of elements to upgrade if that // element is registered as a custom element. diff --git a/dom/bindings/test/test_bug560072.html b/dom/bindings/test/test_bug560072.html index 82bb1c2c6..0eebff116 100644 --- a/dom/bindings/test/test_bug560072.html +++ b/dom/bindings/test/test_bug560072.html @@ -20,11 +20,12 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=560072 /** Test for Bug 560072 **/ is(document.body, - Object.getOwnPropertyDescriptor(HTMLDocument.prototype, "body").get.call(document), + Object.getOwnPropertyDescriptor(Document.prototype, "body").get.call(document), "Should get body out of property descriptor"); is(document.body, - Object.getOwnPropertyDescriptor(Object.getPrototypeOf(document), "body").get.call(document), + Object.getOwnPropertyDescriptor( + Object.getPrototypeOf(Object.getPrototypeOf(document)), "body").get.call(document), "Should get body out of property descriptor this way too"); diff --git a/testing/web-platform/meta/custom-elements/CustomElementRegistry.html.ini b/testing/web-platform/meta/custom-elements/CustomElementRegistry.html.ini index 9e2bf7385..f62b64dfb 100644 --- a/testing/web-platform/meta/custom-elements/CustomElementRegistry.html.ini +++ b/testing/web-platform/meta/custom-elements/CustomElementRegistry.html.ini @@ -1,8 +1,5 @@ [CustomElementRegistry.html] type: testharness - [customElements.define must throw a NotSupportedError when there is already a custom element with the same class] - expected: FAIL - [customElements.define must get callbacks of the constructor prototype] expected: FAIL diff --git a/testing/web-platform/meta/custom-elements/custom-element-registry/define.html.ini b/testing/web-platform/meta/custom-elements/custom-element-registry/define.html.ini deleted file mode 100644 index 122abccd3..000000000 --- a/testing/web-platform/meta/custom-elements/custom-element-registry/define.html.ini +++ /dev/null @@ -1,26 +0,0 @@ -[define.html] - type: testharness - [If constructor is HTMLElement, should throw a TypeError] - expected: FAIL - - [If constructor is HTMLButtonElement, should throw a TypeError] - expected: FAIL - - [If constructor is HTMLImageElement, should throw a TypeError] - expected: FAIL - - [If constructor is HTMLMediaElement, should throw a TypeError] - expected: FAIL - - [If constructor is Image, should throw a TypeError] - expected: FAIL - - [If constructor is Audio, should throw a TypeError] - expected: FAIL - - [If constructor is Option, should throw a TypeError] - expected: FAIL - - [If the constructor is already defined, should throw a NotSupportedError] - expected: FAIL - -- cgit v1.2.3 From 244277a3fa428b70ba46cf611dbe1905733515eb Mon Sep 17 00:00:00 2001 From: Gaming4JC Date: Tue, 7 Jan 2020 20:45:38 -0500 Subject: Bug 1274159 - Part 2-1: Include the name of relevant interface in nsHTMLTagList.h; Tag UXP Issue #1344 --- dom/html/nsHTMLContentSink.cpp | 4 +- parser/htmlparser/nsHTMLTagList.h | 192 ++++++++++++++++++++------------------ parser/htmlparser/nsHTMLTags.cpp | 12 +-- parser/htmlparser/nsHTMLTags.h | 4 +- 4 files changed, 104 insertions(+), 108 deletions(-) diff --git a/dom/html/nsHTMLContentSink.cpp b/dom/html/nsHTMLContentSink.cpp index 3e8e019b8..6e808f87e 100644 --- a/dom/html/nsHTMLContentSink.cpp +++ b/dom/html/nsHTMLContentSink.cpp @@ -96,14 +96,12 @@ NS_NewHTMLNOTUSEDElement(already_AddRefed&& aNodeInfo, return nullptr; } -#define HTML_TAG(_tag, _classname) NS_NewHTML##_classname##Element, -#define HTML_HTMLELEMENT_TAG(_tag) NS_NewHTMLElement, +#define HTML_TAG(_tag, _classname, _interfacename) NS_NewHTML##_classname##Element, #define HTML_OTHER(_tag) NS_NewHTMLNOTUSEDElement, static const contentCreatorCallback sContentCreatorCallbacks[] = { NS_NewHTMLUnknownElement, #include "nsHTMLTagList.h" #undef HTML_TAG -#undef HTML_HTMLELEMENT_TAG #undef HTML_OTHER NS_NewHTMLUnknownElement }; diff --git a/parser/htmlparser/nsHTMLTagList.h b/parser/htmlparser/nsHTMLTagList.h index 7e1e207cc..f5e1da6c1 100644 --- a/parser/htmlparser/nsHTMLTagList.h +++ b/parser/htmlparser/nsHTMLTagList.h @@ -10,8 +10,8 @@ This file contains the list of all HTML tags. See nsHTMLTags.h for access to the enum values for tags. - It is designed to be used as inline input to nsHTMLTags.cpp and - nsHTMLContentSink *only* through the magic of C preprocessing. + It is designed to be used as input to various places that will define the + HTML_TAG macro in useful ways through the magic of C preprocessing. All entries must be enclosed in the macro HTML_TAG which will have cruel and unusual things done to it. @@ -19,11 +19,13 @@ It is recommended (but not strictly necessary) to keep all entries in alphabetical order. - The first argument to HTML_TAG is both the enum identifier of the - property and the string value. The second argument is the "creator" - method of the form NS_New$TAGNAMEElement, that will be used by + The first argument to HTML_TAG is the tag name. The second argument is the + "creator" method of the form NS_New$TAGNAMEElement, that will be used by nsHTMLContentSink.cpp to create a content object for a tag of that type. Use NOTUSED, if the particular tag has a non-standard creator. + The third argument is the interface name specified for this element + in the HTML specification. It can be empty if the relevant interface name + is "HTMLElement". The HTML_OTHER macro is for values in the nsHTMLTag enum that are not strictly tags. @@ -35,104 +37,106 @@ ** Break these invariants and bad things will happen. ** ******/ -HTML_TAG(a, Anchor) +#define HTML_HTMLELEMENT_TAG(_tag) HTML_TAG(_tag, , ) + +HTML_TAG(a, Anchor, Anchor) HTML_HTMLELEMENT_TAG(abbr) HTML_HTMLELEMENT_TAG(acronym) HTML_HTMLELEMENT_TAG(address) -HTML_TAG(applet, SharedObject) -HTML_TAG(area, Area) +HTML_TAG(applet, SharedObject, Applet) +HTML_TAG(area, Area, Area) HTML_HTMLELEMENT_TAG(article) HTML_HTMLELEMENT_TAG(aside) -HTML_TAG(audio, Audio) +HTML_TAG(audio, Audio, Audio) HTML_HTMLELEMENT_TAG(b) -HTML_TAG(base, Shared) +HTML_TAG(base, Shared, Base) HTML_HTMLELEMENT_TAG(basefont) HTML_HTMLELEMENT_TAG(bdo) -HTML_TAG(bgsound, Unknown) +HTML_TAG(bgsound, Unknown, Unknown) HTML_HTMLELEMENT_TAG(big) -HTML_TAG(blockquote, Shared) -HTML_TAG(body, Body) -HTML_TAG(br, BR) -HTML_TAG(button, Button) -HTML_TAG(canvas, Canvas) -HTML_TAG(caption, TableCaption) +HTML_TAG(blockquote, Shared, Quote) +HTML_TAG(body, Body, Body) +HTML_TAG(br, BR, BR) +HTML_TAG(button, Button, Button) +HTML_TAG(canvas, Canvas, Canvas) +HTML_TAG(caption, TableCaption, TableCaption) HTML_HTMLELEMENT_TAG(center) HTML_HTMLELEMENT_TAG(cite) HTML_HTMLELEMENT_TAG(code) -HTML_TAG(col, TableCol) -HTML_TAG(colgroup, TableCol) -HTML_TAG(content, Content) -HTML_TAG(data, Data) -HTML_TAG(datalist, DataList) +HTML_TAG(col, TableCol, TableCol) +HTML_TAG(colgroup, TableCol, TableCol) +HTML_TAG(content, Content, Content) +HTML_TAG(data, Data, Data) +HTML_TAG(datalist, DataList, DataList) HTML_HTMLELEMENT_TAG(dd) -HTML_TAG(del, Mod) -HTML_TAG(details, Details) +HTML_TAG(del, Mod, Mod) +HTML_TAG(details, Details, Details) HTML_HTMLELEMENT_TAG(dfn) -HTML_TAG(dialog, Dialog) -HTML_TAG(dir, Shared) -HTML_TAG(div, Div) -HTML_TAG(dl, SharedList) +HTML_TAG(dialog, Dialog, Dialog) +HTML_TAG(dir, Shared, Directory) +HTML_TAG(div, Div, Div) +HTML_TAG(dl, SharedList, DList) HTML_HTMLELEMENT_TAG(dt) HTML_HTMLELEMENT_TAG(em) -HTML_TAG(embed, SharedObject) -HTML_TAG(fieldset, FieldSet) +HTML_TAG(embed, SharedObject, Embed) +HTML_TAG(fieldset, FieldSet, FieldSet) HTML_HTMLELEMENT_TAG(figcaption) HTML_HTMLELEMENT_TAG(figure) -HTML_TAG(font, Font) +HTML_TAG(font, Font, Font) HTML_HTMLELEMENT_TAG(footer) -HTML_TAG(form, Form) -HTML_TAG(frame, Frame) -HTML_TAG(frameset, FrameSet) -HTML_TAG(h1, Heading) -HTML_TAG(h2, Heading) -HTML_TAG(h3, Heading) -HTML_TAG(h4, Heading) -HTML_TAG(h5, Heading) -HTML_TAG(h6, Heading) -HTML_TAG(head, Shared) +HTML_TAG(form, Form, Form) +HTML_TAG(frame, Frame, Frame) +HTML_TAG(frameset, FrameSet, FrameSet) +HTML_TAG(h1, Heading, Heading) +HTML_TAG(h2, Heading, Heading) +HTML_TAG(h3, Heading, Heading) +HTML_TAG(h4, Heading, Heading) +HTML_TAG(h5, Heading, Heading) +HTML_TAG(h6, Heading, Heading) +HTML_TAG(head, Shared, Head) HTML_HTMLELEMENT_TAG(header) HTML_HTMLELEMENT_TAG(hgroup) -HTML_TAG(hr, HR) -HTML_TAG(html, Shared) +HTML_TAG(hr, HR, HR) +HTML_TAG(html, Shared, Html) HTML_HTMLELEMENT_TAG(i) -HTML_TAG(iframe, IFrame) +HTML_TAG(iframe, IFrame, IFrame) HTML_HTMLELEMENT_TAG(image) -HTML_TAG(img, Image) -HTML_TAG(input, Input) -HTML_TAG(ins, Mod) +HTML_TAG(img, Image, Image) +HTML_TAG(input, Input, Input) +HTML_TAG(ins, Mod, Mod) HTML_HTMLELEMENT_TAG(kbd) -HTML_TAG(keygen, Span) -HTML_TAG(label, Label) -HTML_TAG(legend, Legend) -HTML_TAG(li, LI) -HTML_TAG(link, Link) -HTML_TAG(listing, Pre) +HTML_TAG(keygen, Span, Span) +HTML_TAG(label, Label, Label) +HTML_TAG(legend, Legend, Legend) +HTML_TAG(li, LI, LI) +HTML_TAG(link, Link, Link) +HTML_TAG(listing, Pre, Pre) HTML_HTMLELEMENT_TAG(main) -HTML_TAG(map, Map) +HTML_TAG(map, Map, Map) HTML_HTMLELEMENT_TAG(mark) -HTML_TAG(marquee, Div) -HTML_TAG(menu, Menu) -HTML_TAG(menuitem, MenuItem) -HTML_TAG(meta, Meta) -HTML_TAG(meter, Meter) -HTML_TAG(multicol, Unknown) +HTML_TAG(marquee, Div, Div) +HTML_TAG(menu, Menu, Menu) +HTML_TAG(menuitem, MenuItem, MenuItem) +HTML_TAG(meta, Meta, Meta) +HTML_TAG(meter, Meter, Meter) +HTML_TAG(multicol, Unknown, Unknown) HTML_HTMLELEMENT_TAG(nav) HTML_HTMLELEMENT_TAG(nobr) HTML_HTMLELEMENT_TAG(noembed) HTML_HTMLELEMENT_TAG(noframes) HTML_HTMLELEMENT_TAG(noscript) -HTML_TAG(object, Object) -HTML_TAG(ol, SharedList) -HTML_TAG(optgroup, OptGroup) -HTML_TAG(option, Option) -HTML_TAG(output, Output) -HTML_TAG(p, Paragraph) -HTML_TAG(param, Shared) -HTML_TAG(picture, Picture) +HTML_TAG(object, Object, Object) +HTML_TAG(ol, SharedList, OList) +HTML_TAG(optgroup, OptGroup, OptGroup) +HTML_TAG(option, Option, Option) +HTML_TAG(output, Output, Output) +HTML_TAG(p, Paragraph, Paragraph) +HTML_TAG(param, Shared, Param) +HTML_TAG(picture, Picture, Picture) HTML_HTMLELEMENT_TAG(plaintext) -HTML_TAG(pre, Pre) -HTML_TAG(progress, Progress) -HTML_TAG(q, Shared) +HTML_TAG(pre, Pre, Pre) +HTML_TAG(progress, Progress, Progress) +HTML_TAG(q, Shared, Quote) HTML_HTMLELEMENT_TAG(rb) HTML_HTMLELEMENT_TAG(rp) HTML_HTMLELEMENT_TAG(rt) @@ -140,38 +144,38 @@ HTML_HTMLELEMENT_TAG(rtc) HTML_HTMLELEMENT_TAG(ruby) HTML_HTMLELEMENT_TAG(s) HTML_HTMLELEMENT_TAG(samp) -HTML_TAG(script, Script) +HTML_TAG(script, Script, Script) HTML_HTMLELEMENT_TAG(section) -HTML_TAG(select, Select) -HTML_TAG(shadow, Shadow) +HTML_TAG(select, Select, Select) +HTML_TAG(shadow, Shadow, Shadow) HTML_HTMLELEMENT_TAG(small) -HTML_TAG(source, Source) -HTML_TAG(span, Span) +HTML_TAG(source, Source, Source) +HTML_TAG(span, Span, Span) HTML_HTMLELEMENT_TAG(strike) HTML_HTMLELEMENT_TAG(strong) -HTML_TAG(style, Style) +HTML_TAG(style, Style, Style) HTML_HTMLELEMENT_TAG(sub) -HTML_TAG(summary, Summary) +HTML_TAG(summary, Summary, ) HTML_HTMLELEMENT_TAG(sup) -HTML_TAG(table, Table) -HTML_TAG(tbody, TableSection) -HTML_TAG(td, TableCell) -HTML_TAG(textarea, TextArea) -HTML_TAG(tfoot, TableSection) -HTML_TAG(th, TableCell) -HTML_TAG(thead, TableSection) -HTML_TAG(template, Template) -HTML_TAG(time, Time) -HTML_TAG(title, Title) -HTML_TAG(tr, TableRow) -HTML_TAG(track, Track) +HTML_TAG(table, Table, Table) +HTML_TAG(tbody, TableSection, TableSection) +HTML_TAG(td, TableCell, TableCell) +HTML_TAG(textarea, TextArea, TextArea) +HTML_TAG(tfoot, TableSection, TableSection) +HTML_TAG(th, TableCell, TableCell) +HTML_TAG(thead, TableSection, TableSection) +HTML_TAG(template, Template, Template) +HTML_TAG(time, Time, Time) +HTML_TAG(title, Title, Title) +HTML_TAG(tr, TableRow, TableRow) +HTML_TAG(track, Track, Track) HTML_HTMLELEMENT_TAG(tt) HTML_HTMLELEMENT_TAG(u) -HTML_TAG(ul, SharedList) +HTML_TAG(ul, SharedList, UList) HTML_HTMLELEMENT_TAG(var) -HTML_TAG(video, Video) +HTML_TAG(video, Video, Video) HTML_HTMLELEMENT_TAG(wbr) -HTML_TAG(xmp, Pre) +HTML_TAG(xmp, Pre, Pre) /* These are not for tags. But they will be included in the nsHTMLTag @@ -185,3 +189,5 @@ HTML_OTHER(entity) HTML_OTHER(doctypeDecl) HTML_OTHER(markupDecl) HTML_OTHER(instruction) + +#undef HTML_HTMLELEMENT_TAG diff --git a/parser/htmlparser/nsHTMLTags.cpp b/parser/htmlparser/nsHTMLTags.cpp index d5a68d46a..e98d2c4cd 100644 --- a/parser/htmlparser/nsHTMLTags.cpp +++ b/parser/htmlparser/nsHTMLTags.cpp @@ -15,14 +15,12 @@ using namespace mozilla; // static array of unicode tag names -#define HTML_TAG(_tag, _classname) (u"" #_tag), -#define HTML_HTMLELEMENT_TAG(_tag) (u"" #_tag), +#define HTML_TAG(_tag, _classname, _interfacename) (u"" #_tag), #define HTML_OTHER(_tag) const char16_t* const nsHTMLTags::sTagUnicodeTable[] = { #include "nsHTMLTagList.h" }; #undef HTML_TAG -#undef HTML_HTMLELEMENT_TAG #undef HTML_OTHER // static array of tag atoms @@ -62,23 +60,19 @@ HTMLTagsHashCodeAtom(const void *key) void nsHTMLTags::RegisterAtoms(void) { -#define HTML_TAG(_tag, _classname) NS_STATIC_ATOM_BUFFER(Atombuffer_##_tag, #_tag) -#define HTML_HTMLELEMENT_TAG(_tag) NS_STATIC_ATOM_BUFFER(Atombuffer_##_tag, #_tag) +#define HTML_TAG(_tag, _classname, _interfacename) NS_STATIC_ATOM_BUFFER(Atombuffer_##_tag, #_tag) #define HTML_OTHER(_tag) #include "nsHTMLTagList.h" #undef HTML_TAG -#undef HTML_HTMLELEMENT_TAG #undef HTML_OTHER // static array of tag StaticAtom structs -#define HTML_TAG(_tag, _classname) NS_STATIC_ATOM(Atombuffer_##_tag, &nsHTMLTags::sTagAtomTable[eHTMLTag_##_tag - 1]), -#define HTML_HTMLELEMENT_TAG(_tag) NS_STATIC_ATOM(Atombuffer_##_tag, &nsHTMLTags::sTagAtomTable[eHTMLTag_##_tag - 1]), +#define HTML_TAG(_tag, _classname, _interfacename) NS_STATIC_ATOM(Atombuffer_##_tag, &nsHTMLTags::sTagAtomTable[eHTMLTag_##_tag - 1]), #define HTML_OTHER(_tag) static const nsStaticAtom sTagAtoms_info[] = { #include "nsHTMLTagList.h" }; #undef HTML_TAG -#undef HTML_HTMLELEMENT_TAG #undef HTML_OTHER // Fill in our static atom pointers diff --git a/parser/htmlparser/nsHTMLTags.h b/parser/htmlparser/nsHTMLTags.h index 8f0c86b4b..a2800df07 100644 --- a/parser/htmlparser/nsHTMLTags.h +++ b/parser/htmlparser/nsHTMLTags.h @@ -18,8 +18,7 @@ class nsIAtom; To change the list of tags, see nsHTMLTagList.h */ -#define HTML_TAG(_tag, _classname) eHTMLTag_##_tag, -#define HTML_HTMLELEMENT_TAG(_tag) eHTMLTag_##_tag, +#define HTML_TAG(_tag, _classname, _interfacename) eHTMLTag_##_tag, #define HTML_OTHER(_tag) eHTMLTag_##_tag, enum nsHTMLTag { /* this enum must be first and must be zero */ @@ -31,7 +30,6 @@ enum nsHTMLTag { eHTMLTag_userdefined }; #undef HTML_TAG -#undef HTML_HTMLELEMENT_TAG #undef HTML_OTHER // All tags before eHTMLTag_text are HTML tags -- cgit v1.2.3 From 5222f6e9daa4cb74b404f769b23510b3d600efd9 Mon Sep 17 00:00:00 2001 From: Gaming4JC Date: Thu, 2 Jan 2020 21:25:47 -0500 Subject: Bug 1274159 - Part 2-2: Support HTMLConstructor WebIDL extended attribute for custom elements; Tag UXP Issue #1344 --- dom/base/CustomElementRegistry.cpp | 17 +++ dom/base/CustomElementRegistry.h | 7 + dom/bindings/BindingUtils.cpp | 153 +++++++++++++++++++ dom/bindings/BindingUtils.h | 8 + dom/bindings/Bindings.conf | 5 + dom/bindings/Codegen.py | 132 +++++++++++++--- dom/bindings/parser/WebIDL.py | 29 +++- dom/bindings/parser/tests/test_constructor.py | 166 ++++++++++++++++++++- .../tests/test_constructor_no_interface_object.py | 33 ++++ dom/bindings/test/TestBindingHeader.h | 6 + dom/bindings/test/TestCodeGen.webidl | 4 + parser/htmlparser/nsHTMLTags.h | 4 + 12 files changed, 534 insertions(+), 30 deletions(-) diff --git a/dom/base/CustomElementRegistry.cpp b/dom/base/CustomElementRegistry.cpp index 43e4e7e2a..6cd213210 100644 --- a/dom/base/CustomElementRegistry.cpp +++ b/dom/base/CustomElementRegistry.cpp @@ -273,6 +273,23 @@ CustomElementRegistry::LookupCustomElementDefinition(const nsAString& aLocalName return nullptr; } +CustomElementDefinition* +CustomElementRegistry::LookupCustomElementDefinition(JSContext* aCx, + JSObject* aConstructor) const +{ + JS::Rooted constructor(aCx, js::CheckedUnwrap(aConstructor)); + + const auto& ptr = mConstructors.lookup(constructor); + if (!ptr) { + return nullptr; + } + + CustomElementDefinition* definition = mCustomDefinitions.Get(ptr->value()); + MOZ_ASSERT(definition, "Definition must be found in mCustomDefinitions"); + + return definition; +} + void CustomElementRegistry::RegisterUnresolvedElement(Element* aElement, nsIAtom* aTypeName) { diff --git a/dom/base/CustomElementRegistry.h b/dom/base/CustomElementRegistry.h index 9034dd7ea..8ef0785af 100644 --- a/dom/base/CustomElementRegistry.h +++ b/dom/base/CustomElementRegistry.h @@ -128,6 +128,10 @@ struct CustomElementDefinition // The document custom element order. uint32_t mDocOrder; + + bool IsCustomBuiltIn() { + return mType != mLocalName; + } }; class CustomElementRegistry final : public nsISupports, @@ -155,6 +159,9 @@ public: CustomElementDefinition* LookupCustomElementDefinition( const nsAString& aLocalName, const nsAString* aIs = nullptr) const; + CustomElementDefinition* LookupCustomElementDefinition( + JSContext* aCx, JSObject *aConstructor) const; + /** * Enqueue created callback or register upgrade candidate for * newly created custom elements, possibly extending an existing type. diff --git a/dom/bindings/BindingUtils.cpp b/dom/bindings/BindingUtils.cpp index b244d4d2a..6bc6b7143 100644 --- a/dom/bindings/BindingUtils.cpp +++ b/dom/bindings/BindingUtils.cpp @@ -19,10 +19,12 @@ #include "AccessCheck.h" #include "jsfriendapi.h" +#include "nsContentCreatorFunctions.h" #include "nsContentUtils.h" #include "nsGlobalWindow.h" #include "nsIDocShell.h" #include "nsIDOMGlobalPropertyInitializer.h" +#include "nsIParserService.h" #include "nsIPermissionManager.h" #include "nsIPrincipal.h" #include "nsIXPConnect.h" @@ -37,6 +39,7 @@ #include "nsGlobalWindow.h" #include "mozilla/dom/ScriptSettings.h" +#include "mozilla/dom/CustomElementRegistry.h" #include "mozilla/dom/DOMError.h" #include "mozilla/dom/DOMErrorBinding.h" #include "mozilla/dom/DOMException.h" @@ -44,6 +47,7 @@ #include "mozilla/dom/HTMLObjectElement.h" #include "mozilla/dom/HTMLObjectElementBinding.h" #include "mozilla/dom/HTMLSharedObjectElement.h" +#include "mozilla/dom/HTMLElementBinding.h" #include "mozilla/dom/HTMLEmbedElementBinding.h" #include "mozilla/dom/HTMLAppletElementBinding.h" #include "mozilla/dom/Promise.h" @@ -62,6 +66,30 @@ namespace dom { using namespace workers; +// Forward declare GetConstructorObject methods. +#define HTML_TAG(_tag, _classname, _interfacename) \ +namespace HTML##_interfacename##ElementBinding { \ + JSObject* GetConstructorObject(JSContext*); \ +} +#define HTML_OTHER(_tag) +#include "nsHTMLTagList.h" +#undef HTML_TAG +#undef HTML_OTHER + +typedef JSObject* (*constructorGetterCallback)(JSContext*); + +// Mapping of html tag and GetConstructorObject methods. +#define HTML_TAG(_tag, _classname, _interfacename) HTML##_interfacename##ElementBinding::GetConstructorObject, +#define HTML_OTHER(_tag) nullptr, +// We use eHTMLTag_foo (where foo is the tag) which is defined in nsHTMLTags.h +// to index into this array. +static const constructorGetterCallback sConstructorGetterCallback[] = { + HTMLUnknownElementBinding::GetConstructorObject, +#include "nsHTMLTagList.h" +#undef HTML_TAG +#undef HTML_OTHER +}; + const JSErrorFormatString ErrorFormatString[] = { #define MSG_DEF(_name, _argc, _exn, _str) \ { #_name, _str, _argc, _exn }, @@ -3377,6 +3405,131 @@ GetDesiredProto(JSContext* aCx, const JS::CallArgs& aCallArgs, return true; } +// https://html.spec.whatwg.org/multipage/dom.html#htmlconstructor +already_AddRefed +CreateHTMLElement(const GlobalObject& aGlobal, const JS::CallArgs& aCallArgs, + ErrorResult& aRv) +{ + // Step 1. + nsCOMPtr window = do_QueryInterface(aGlobal.GetAsSupports()); + if (!window) { + aRv.Throw(NS_ERROR_UNEXPECTED); + return nullptr; + } + + nsIDocument* doc = window->GetExtantDoc(); + if (!doc) { + aRv.Throw(NS_ERROR_UNEXPECTED); + return nullptr; + } + + RefPtr registry(window->CustomElements()); + if (!registry) { + aRv.Throw(NS_ERROR_UNEXPECTED); + return nullptr; + } + + // Step 2 is in the code output by CGClassConstructor. + // Step 3. + JSContext* cx = aGlobal.Context(); + JS::Rooted newTarget(cx, &aCallArgs.newTarget().toObject()); + CustomElementDefinition* definition = + registry->LookupCustomElementDefinition(cx, newTarget); + if (!definition) { + aRv.ThrowTypeError(); + return nullptr; + } + + // The callee might be an Xray. Unwrap it to get actual callee. + JS::Rooted callee(cx, js::CheckedUnwrap(&aCallArgs.callee())); + if (!callee) { + aRv.Throw(NS_ERROR_DOM_SECURITY_ERR); + return nullptr; + } + + // And the actual callee might be in different compartment, so enter its + // compartment before getting the standard constructor object to compare to, + // so we get it from the same global as callee itself. + JSAutoCompartment ac(cx, callee); + int32_t tag = eHTMLTag_userdefined; + if (!definition->IsCustomBuiltIn()) { + // Step 4. + // If the definition is for an autonomous custom element, the active + // function should be HTMLElement. + JS::Rooted constructor(cx, HTMLElementBinding::GetConstructorObject(cx)); + if (!constructor) { + aRv.NoteJSContextException(cx); + return nullptr; + } + + if (callee != constructor) { + aRv.ThrowTypeError(); + return nullptr; + } + } else { + // Step 5. + // If the definition is for a customized built-in element, the localName + // should be defined in the specification. + nsIParserService* parserService = nsContentUtils::GetParserService(); + if (!parserService) { + aRv.Throw(NS_ERROR_UNEXPECTED); + return nullptr; + } + + tag = parserService->HTMLCaseSensitiveAtomTagToId(definition->mLocalName); + if (tag == eHTMLTag_userdefined) { + aRv.ThrowTypeError(); + return nullptr; + } + + MOZ_ASSERT(tag <= NS_HTML_TAG_MAX, "tag is out of bounds"); + + // If the definition is for a customized built-in element, the active + // function should be the localname's element interface. + constructorGetterCallback cb = sConstructorGetterCallback[tag]; + if (!cb) { + aRv.ThrowTypeError(); + return nullptr; + } + + JS::Rooted constructor(cx, cb(cx)); + if (!constructor) { + aRv.NoteJSContextException(cx); + return nullptr; + } + + if (callee != constructor) { + aRv.ThrowTypeError(); + return nullptr; + } + } + + RefPtr nodeInfo = + doc->NodeInfoManager()->GetNodeInfo(definition->mLocalName, + nullptr, + kNameSpaceID_XHTML, + nsIDOMNode::ELEMENT_NODE); + if (!nodeInfo) { + aRv.Throw(NS_ERROR_UNEXPECTED); + return nullptr; + } + + // Step 6 and Step 7 are in the code output by CGClassConstructor. + // Step 8. + // Construction stack will be implemented in bug 1287348. So we always run + // "construction stack is empty" case for now. + RefPtr element; + if (tag == eHTMLTag_userdefined) { + // Autonomous custom element. + element = NS_NewHTMLElement(nodeInfo.forget()); + } else { + // Customized built-in element. + element = CreateHTMLElement(tag, nodeInfo.forget(), NOT_FROM_PARSER); + } + + return element.forget(); +} + #ifdef DEBUG namespace binding_detail { void diff --git a/dom/bindings/BindingUtils.h b/dom/bindings/BindingUtils.h index 5cab835b3..2563c5fee 100644 --- a/dom/bindings/BindingUtils.h +++ b/dom/bindings/BindingUtils.h @@ -42,6 +42,7 @@ #include "nsWrapperCacheInlines.h" +class nsGenericHTMLElement; class nsIJSID; namespace mozilla { @@ -3420,6 +3421,13 @@ bool GetDesiredProto(JSContext* aCx, const JS::CallArgs& aCallArgs, JS::MutableHandle aDesiredProto); +// This function is expected to be called from the constructor function for an +// HTML element interface; the global/callargs need to be whatever was passed to +// that constructor function. +already_AddRefed +CreateHTMLElement(const GlobalObject& aGlobal, const JS::CallArgs& aCallArgs, + ErrorResult& aRv); + void SetDocumentAndPageUseCounter(JSContext* aCx, JSObject* aObject, UseCounter aUseCounter); diff --git a/dom/bindings/Bindings.conf b/dom/bindings/Bindings.conf index b00af2085..6eebaf60c 100644 --- a/dom/bindings/Bindings.conf +++ b/dom/bindings/Bindings.conf @@ -1638,6 +1638,11 @@ DOMInterfaces = { 'register': False, }, +'TestHTMLConstructorInterface' : { + 'headerFile': 'TestBindingHeader.h', + 'register': False, + }, + } # These are temporary, until they've been converted to use new DOM bindings diff --git a/dom/bindings/Codegen.py b/dom/bindings/Codegen.py index 6b23e8225..676d91793 100644 --- a/dom/bindings/Codegen.py +++ b/dom/bindings/Codegen.py @@ -1747,6 +1747,71 @@ class CGClassConstructor(CGAbstractStaticMethod): else: ctorName = self.descriptor.interface.identifier.name + # [HTMLConstructor] for custom element + # This needs to live in bindings code because it directly examines + # newtarget and the callee function to do HTMLConstructor specific things. + if self._ctor.isHTMLConstructor(): + htmlConstructorSanityCheck = dedent(""" + // The newTarget might be a cross-compartment wrapper. Get the underlying object + // so we can do the spec's object-identity checks. + JS::Rooted newTarget(cx, js::CheckedUnwrap(&args.newTarget().toObject())); + if (!newTarget) { + return ThrowErrorMessage(cx, MSG_ILLEGAL_CONSTRUCTOR); + } + + // Step 2 of https://html.spec.whatwg.org/multipage/dom.html#htmlconstructor. + // Enter the compartment of our underlying newTarget object, so we end + // up comparing to the constructor object for our interface from that global. + { + JSAutoCompartment ac(cx, newTarget); + JS::Handle constructor(GetConstructorObjectHandle(cx)); + if (!constructor) { + return false; + } + if (newTarget == constructor) { + return ThrowErrorMessage(cx, MSG_ILLEGAL_CONSTRUCTOR); + } + } + + """) + + # If we are unable to get desired prototype from newTarget, then we + # fall back to the interface prototype object from newTarget's realm. + htmlConstructorFallback = dedent(""" + if (!desiredProto) { + // Step 7 of https://html.spec.whatwg.org/multipage/dom.html#htmlconstructor. + // This fallback behavior is designed to match analogous behavior for the + // JavaScript built-ins. So we enter the compartment of our underlying + // newTarget object and fall back to the prototype object from that global. + // XXX The spec says to use GetFunctionRealm(), which is not actually + // the same thing as what we have here (e.g. in the case of scripted callable proxies + // whose target is not same-compartment with the proxy, or bound functions, etc). + // https://bugzilla.mozilla.org/show_bug.cgi?id=1317658 + { + JSAutoCompartment ac(cx, newTarget); + desiredProto = GetProtoObjectHandle(cx); + if (!desiredProto) { + return false; + } + } + + // desiredProto is in the compartment of the underlying newTarget object. + // Wrap it into the context compartment. + if (!JS_WrapObject(cx, &desiredProto)) { + return false; + } + } + """) + else: + htmlConstructorSanityCheck = "" + htmlConstructorFallback = "" + + + # If we're a constructor, "obj" may not be a function, so calling + # XrayAwareCalleeGlobal() on it is not safe. Of course in the + # constructor case either "obj" is an Xray or we're already in the + # content compartment, not the Xray compartment, so just + # constructing the GlobalObject from "obj" is fine. preamble = fill( """ JS::CallArgs args = JS::CallArgsFromVp(argc, vp); @@ -1757,19 +1822,41 @@ class CGClassConstructor(CGAbstractStaticMethod): // Adding more relocations return ThrowConstructorWithoutNew(cx, "${ctorName}"); } + + GlobalObject global(cx, obj); + if (global.Failed()) { + return false; + } + + $*{htmlConstructorSanityCheck} JS::Rooted desiredProto(cx); if (!GetDesiredProto(cx, args, &desiredProto)) { return false; } + $*{htmlConstructorFallback} """, chromeOnlyCheck=chromeOnlyCheck, - ctorName=ctorName) - - name = self._ctor.identifier.name - nativeName = MakeNativeName(self.descriptor.binaryNameFor(name)) - callGenerator = CGMethodCall(nativeName, True, self.descriptor, - self._ctor, isConstructor=True, - constructorName=ctorName) + ctorName=ctorName, + htmlConstructorSanityCheck=htmlConstructorSanityCheck, + htmlConstructorFallback=htmlConstructorFallback) + + if self._ctor.isHTMLConstructor(): + signatures = self._ctor.signatures() + assert len(signatures) == 1 + # Given that HTMLConstructor takes no args, we can just codegen a + # call to CreateHTMLElement() in BindingUtils which reuses the + # factory thing in HTMLContentSink. Then we don't have to implement + # Constructor on all the HTML elements. + callGenerator = CGPerSignatureCall(signatures[0][0], signatures[0][1], + "CreateHTMLElement", True, + self.descriptor, self._ctor, + isConstructor=True) + else: + name = self._ctor.identifier.name + nativeName = MakeNativeName(self.descriptor.binaryNameFor(name)) + callGenerator = CGMethodCall(nativeName, True, self.descriptor, + self._ctor, isConstructor=True, + constructorName=ctorName) return preamble + "\n" + callGenerator.define() @@ -7440,26 +7527,23 @@ class CGPerSignatureCall(CGThing): argsPre = [] if idlNode.isStatic(): - # If we're a constructor, "obj" may not be a function, so calling - # XrayAwareCalleeGlobal() on it is not safe. Of course in the - # constructor case either "obj" is an Xray or we're already in the - # content compartment, not the Xray compartment, so just - # constructing the GlobalObject from "obj" is fine. - if isConstructor: - objForGlobalObject = "obj" - else: - objForGlobalObject = "xpc::XrayAwareCalleeGlobal(obj)" - cgThings.append(CGGeneric(fill( - """ - GlobalObject global(cx, ${obj}); - if (global.Failed()) { - return false; - } + # If we're a constructor, the GlobalObject struct will be created in + # CGClassConstructor. + if not isConstructor: + cgThings.append(CGGeneric(dedent( + """ + GlobalObject global(cx, xpc::XrayAwareCalleeGlobal(obj)); + if (global.Failed()) { + return false; + } + + """))) - """, - obj=objForGlobalObject))) argsPre.append("global") + if isConstructor and idlNode.isHTMLConstructor(): + argsPre.append("args") + # For JS-implemented interfaces we do not want to base the # needsCx decision on the types involved, just on our extended # attributes. Also, JSContext is not needed for the static case diff --git a/dom/bindings/parser/WebIDL.py b/dom/bindings/parser/WebIDL.py index 4f602365b..a89620a9f 100644 --- a/dom/bindings/parser/WebIDL.py +++ b/dom/bindings/parser/WebIDL.py @@ -1582,7 +1582,7 @@ class IDLInterface(IDLInterfaceOrNamespace): [self.location]) self._noInterfaceObject = True - elif identifier == "Constructor" or identifier == "NamedConstructor" or identifier == "ChromeConstructor": + elif identifier == "Constructor" or identifier == "NamedConstructor" or identifier == "ChromeConstructor" or identifier == "HTMLConstructor": if identifier == "Constructor" and not self.hasInterfaceObject(): raise WebIDLError(str(identifier) + " and NoInterfaceObject are incompatible", [self.location]) @@ -1595,11 +1595,20 @@ class IDLInterface(IDLInterfaceOrNamespace): raise WebIDLError(str(identifier) + " and NoInterfaceObject are incompatible", [self.location]) + if identifier == "HTMLConstructor": + if not self.hasInterfaceObject(): + raise WebIDLError(str(identifier) + " and NoInterfaceObject are incompatible", + [self.location]) + + if not attr.noArguments(): + raise WebIDLError(str(identifier) + " must take no arguments", + [attr.location]) + args = attr.args() if attr.hasArgs() else [] retType = IDLWrapperType(self.location, self) - if identifier == "Constructor" or identifier == "ChromeConstructor": + if identifier == "Constructor" or identifier == "ChromeConstructor" or identifier == "HTMLConstructor": name = "constructor" allowForbidden = True else: @@ -1610,7 +1619,8 @@ class IDLInterface(IDLInterfaceOrNamespace): allowForbidden=allowForbidden) method = IDLMethod(self.location, methodIdentifier, retType, - args, static=True) + args, static=True, + htmlConstructor=(identifier == "HTMLConstructor")) # Constructors are always NewObject and are always # assumed to be able to throw (since there's no way to # indicate otherwise) and never have any other @@ -1622,7 +1632,7 @@ class IDLInterface(IDLInterfaceOrNamespace): method.addExtendedAttributes( [IDLExtendedAttribute(self.location, ("ChromeOnly",))]) - if identifier == "Constructor" or identifier == "ChromeConstructor": + if identifier == "Constructor" or identifier == "ChromeConstructor" or identifier == "HTMLConstructor": method.resolve(self) else: # We need to detect conflicts for NamedConstructors across @@ -4537,7 +4547,7 @@ class IDLMethod(IDLInterfaceMember, IDLScope): static=False, getter=False, setter=False, creator=False, deleter=False, specialType=NamedOrIndexed.Neither, legacycaller=False, stringifier=False, jsonifier=False, - maplikeOrSetlikeOrIterable=None): + maplikeOrSetlikeOrIterable=None, htmlConstructor=False): # REVIEW: specialType is NamedOrIndexed -- wow, this is messed up. IDLInterfaceMember.__init__(self, location, identifier, IDLInterfaceMember.Tags.Method) @@ -4567,6 +4577,10 @@ class IDLMethod(IDLInterfaceMember, IDLScope): self._jsonifier = jsonifier assert maplikeOrSetlikeOrIterable is None or isinstance(maplikeOrSetlikeOrIterable, IDLMaplikeOrSetlikeOrIterableBase) self.maplikeOrSetlikeOrIterable = maplikeOrSetlikeOrIterable + assert isinstance(htmlConstructor, bool) + # The identifier of a HTMLConstructor must be 'constructor'. + assert not htmlConstructor or identifier.name == "constructor" + self._htmlConstructor = htmlConstructor self._specialType = specialType self._unforgeable = False self.dependsOn = "Everything" @@ -4667,6 +4681,9 @@ class IDLMethod(IDLInterfaceMember, IDLScope): self.isStringifier() or self.isJsonifier()) + def isHTMLConstructor(self): + return self._htmlConstructor + def hasOverloads(self): return self._hasOverloads @@ -4722,6 +4739,8 @@ class IDLMethod(IDLInterfaceMember, IDLScope): assert not method.isStringifier() assert not self.isJsonifier() assert not method.isJsonifier() + assert not self.isHTMLConstructor() + assert not method.isHTMLConstructor() return self diff --git a/dom/bindings/parser/tests/test_constructor.py b/dom/bindings/parser/tests/test_constructor.py index 348204c7d..fb651c08d 100644 --- a/dom/bindings/parser/tests/test_constructor.py +++ b/dom/bindings/parser/tests/test_constructor.py @@ -13,7 +13,7 @@ def WebIDLTest(parser, harness): def checkMethod(method, QName, name, signatures, static=True, getter=False, setter=False, creator=False, deleter=False, legacycaller=False, stringifier=False, - chromeOnly=False): + chromeOnly=False, htmlConstructor=False): harness.ok(isinstance(method, WebIDL.IDLMethod), "Should be an IDLMethod") harness.ok(method.isMethod(), "Method is a method") @@ -29,6 +29,7 @@ def WebIDLTest(parser, harness): harness.check(method.isLegacycaller(), legacycaller, "Method has the correct legacycaller value") harness.check(method.isStringifier(), stringifier, "Method has the correct stringifier value") harness.check(method.getExtendedAttribute("ChromeOnly") is not None, chromeOnly, "Method has the correct value for ChromeOnly") + harness.check(method.isHTMLConstructor(), htmlConstructor, "Method has the correct htmlConstructor value") harness.check(len(method.signatures()), len(signatures), "Method has the correct number of signatures") sigpairs = zip(method.signatures(), signatures) @@ -78,6 +79,21 @@ def WebIDLTest(parser, harness): ("TestConstructorOverloads (Wrapper)", [("::TestConstructorOverloads::constructor::bar", "bar", "Boolean", False, False)])]) + parser = parser.reset() + parser.parse(""" + [HTMLConstructor] + interface TestHTMLConstructor { + }; + """) + results = parser.finish() + harness.check(len(results), 1, "Should be one production") + harness.ok(isinstance(results[0], WebIDL.IDLInterface), + "Should be an IDLInterface") + + checkMethod(results[0].ctor(), "::TestHTMLConstructor::constructor", + "constructor", [("TestHTMLConstructor (Wrapper)", [])], + htmlConstructor=True) + parser = parser.reset() parser.parse(""" [ChromeConstructor()] @@ -107,3 +123,151 @@ def WebIDLTest(parser, harness): threw = True harness.ok(threw, "Can't have both a Constructor and a ChromeConstructor") + + # Test HTMLConstructor with argument + parser = parser.reset() + threw = False + try: + parser.parse(""" + [HTMLConstructor(DOMString a)] + interface TestHTMLConstructorWithArgs { + }; + """) + results = parser.finish() + except: + threw = True + + harness.ok(threw, "HTMLConstructor should take no argument") + + # Test HTMLConstructor on a callback interface + parser = parser.reset() + threw = False + try: + parser.parse(""" + [HTMLConstructor] + callback interface TestHTMLConstructorOnCallbackInterface { + }; + """) + results = parser.finish() + except: + threw = True + + harness.ok(threw, "HTMLConstructor can't be used on a callback interface") + + # Test HTMLConstructor and Constructor + parser = parser.reset() + threw = False + try: + parser.parse(""" + [Constructor, + HTMLConstructor] + interface TestHTMLConstructorAndConstructor { + }; + """) + results = parser.finish() + except: + threw = True + + harness.ok(threw, "Can't have both a Constructor and a HTMLConstructor") + + parser = parser.reset() + threw = False + try: + parser.parse(""" + [HTMLConstructor, + Constructor] + interface TestHTMLConstructorAndConstructor { + }; + """) + results = parser.finish() + except: + threw = True + + harness.ok(threw, "Can't have both a HTMLConstructor and a Constructor") + + parser = parser.reset() + threw = False + try: + parser.parse(""" + [HTMLConstructor, + Constructor(DOMString a)] + interface TestHTMLConstructorAndConstructor { + }; + """) + except: + threw = True + + harness.ok(threw, "Can't have both a HTMLConstructor and a Constructor") + + parser = parser.reset() + threw = False + try: + parser.parse(""" + [Constructor(DOMString a), + HTMLConstructor] + interface TestHTMLConstructorAndConstructor { + }; + """) + except: + threw = True + + harness.ok(threw, "Can't have both a HTMLConstructor and a Constructor") + + # Test HTMLConstructor and ChromeConstructor + parser = parser.reset() + threw = False + try: + parser.parse(""" + [ChromeConstructor, + HTMLConstructor] + interface TestHTMLConstructorAndChromeConstructor { + }; + """) + results = parser.finish() + except: + threw = True + + harness.ok(threw, "Can't have both a HTMLConstructor and a ChromeConstructor") + + parser = parser.reset() + threw = False + try: + parser.parse(""" + [HTMLConstructor, + ChromeConstructor] + interface TestHTMLConstructorAndChromeConstructor { + }; + """) + results = parser.finish() + except: + threw = True + + harness.ok(threw, "Can't have both a HTMLConstructor and a ChromeConstructor") + + parser = parser.reset() + threw = False + try: + parser.parse(""" + [ChromeConstructor(DOMString a), + HTMLConstructor] + interface TestHTMLConstructorAndChromeConstructor { + }; + """) + results = parser.finish() + except: + threw = True + + parser = parser.reset() + threw = False + try: + parser.parse(""" + [HTMLConstructor, + ChromeConstructor(DOMString a)] + interface TestHTMLConstructorAndChromeConstructor { + }; + """) + results = parser.finish() + except: + threw = True + + harness.ok(threw, "Can't have both a HTMLConstructor and a ChromeConstructor") \ No newline at end of file diff --git a/dom/bindings/parser/tests/test_constructor_no_interface_object.py b/dom/bindings/parser/tests/test_constructor_no_interface_object.py index 2b09ae71e..af7b73d67 100644 --- a/dom/bindings/parser/tests/test_constructor_no_interface_object.py +++ b/dom/bindings/parser/tests/test_constructor_no_interface_object.py @@ -34,3 +34,36 @@ def WebIDLTest(parser, harness): interface TestNamedConstructorNoInterfaceObject { }; """) + + # Test HTMLConstructor and NoInterfaceObject + parser = parser.reset() + + threw = False + try: + parser.parse(""" + [NoInterfaceObject, HTMLConstructor] + interface TestHTMLConstructorNoInterfaceObject { + }; + """) + + results = parser.finish() + except: + threw = True + + harness.ok(threw, "Should have thrown.") + + parser = parser.reset() + + threw = False + try: + parser.parse(""" + [HTMLConstructor, NoInterfaceObject] + interface TestHTMLConstructorNoInterfaceObject { + }; + """) + + results = parser.finish() + except: + threw = True + + harness.ok(threw, "Should have thrown.") \ No newline at end of file diff --git a/dom/bindings/test/TestBindingHeader.h b/dom/bindings/test/TestBindingHeader.h index ca5aafdc5..9bd3e407f 100644 --- a/dom/bindings/test/TestBindingHeader.h +++ b/dom/bindings/test/TestBindingHeader.h @@ -1425,6 +1425,12 @@ public: void SetNeedsCallerTypeAttr(bool, CallerType); }; +class TestHTMLConstructorInterface : public nsGenericHTMLElement +{ +public: + virtual nsISupports* GetParentObject(); +}; + } // namespace dom } // namespace mozilla diff --git a/dom/bindings/test/TestCodeGen.webidl b/dom/bindings/test/TestCodeGen.webidl index 4fb9be270..35777f6aa 100644 --- a/dom/bindings/test/TestCodeGen.webidl +++ b/dom/bindings/test/TestCodeGen.webidl @@ -1262,3 +1262,7 @@ interface TestWorkerExposedInterface { [NeedsCallerType] void needsCallerTypeMethod(); [NeedsCallerType] attribute boolean needsCallerTypeAttr; }; + +[HTMLConstructor] +interface TestHTMLConstructorInterface { +}; diff --git a/parser/htmlparser/nsHTMLTags.h b/parser/htmlparser/nsHTMLTags.h index a2800df07..27a23b89f 100644 --- a/parser/htmlparser/nsHTMLTags.h +++ b/parser/htmlparser/nsHTMLTags.h @@ -17,6 +17,10 @@ class nsIAtom; To change the list of tags, see nsHTMLTagList.h + These enum values are used as the index of array in various places. + If we change the structure of the enum by adding entries to it or removing + entries from it _directly_, not via nsHTMLTagList.h, don't forget to update + dom/bindings/BindingUtils.cpp and dom/html/nsHTMLContentSink.cpp as well. */ #define HTML_TAG(_tag, _classname, _interfacename) eHTMLTag_##_tag, #define HTML_OTHER(_tag) eHTMLTag_##_tag, -- cgit v1.2.3 From 6ea0acf750ea7ba38b86cae1f3c6ba8d239c6e9e Mon Sep 17 00:00:00 2001 From: Gaming4JC Date: Thu, 2 Jan 2020 21:46:47 -0500 Subject: Bug 1274159 - Part 3-1: Add HTMLConstructor to HTMLElement and its subclass; Tag UXP Issue #1344 --- dom/webidl/HTMLAnchorElement.webidl | 1 + dom/webidl/HTMLAreaElement.webidl | 1 + dom/webidl/HTMLAudioElement.webidl | 2 +- dom/webidl/HTMLBRElement.webidl | 1 + dom/webidl/HTMLBaseElement.webidl | 1 + dom/webidl/HTMLBodyElement.webidl | 1 + dom/webidl/HTMLButtonElement.webidl | 1 + dom/webidl/HTMLCanvasElement.webidl | 1 + dom/webidl/HTMLDListElement.webidl | 1 + dom/webidl/HTMLDataElement.webidl | 1 + dom/webidl/HTMLDataListElement.webidl | 1 + dom/webidl/HTMLDetailsElement.webidl | 1 + dom/webidl/HTMLDirectoryElement.webidl | 1 + dom/webidl/HTMLDivElement.webidl | 1 + dom/webidl/HTMLElement.webidl | 1 + dom/webidl/HTMLEmbedElement.webidl | 2 +- dom/webidl/HTMLFieldSetElement.webidl | 1 + dom/webidl/HTMLFontElement.webidl | 1 + dom/webidl/HTMLFormElement.webidl | 2 +- dom/webidl/HTMLFrameElement.webidl | 1 + dom/webidl/HTMLFrameSetElement.webidl | 1 + dom/webidl/HTMLHRElement.webidl | 1 + dom/webidl/HTMLHeadElement.webidl | 1 + dom/webidl/HTMLHeadingElement.webidl | 1 + dom/webidl/HTMLHtmlElement.webidl | 1 + dom/webidl/HTMLIFrameElement.webidl | 1 + dom/webidl/HTMLImageElement.webidl | 3 ++- dom/webidl/HTMLInputElement.webidl | 1 + dom/webidl/HTMLLIElement.webidl | 1 + dom/webidl/HTMLLabelElement.webidl | 1 + dom/webidl/HTMLLegendElement.webidl | 1 + dom/webidl/HTMLLinkElement.webidl | 1 + dom/webidl/HTMLMapElement.webidl | 1 + dom/webidl/HTMLMenuElement.webidl | 1 + dom/webidl/HTMLMenuItemElement.webidl | 1 + dom/webidl/HTMLMetaElement.webidl | 1 + dom/webidl/HTMLMeterElement.webidl | 1 + dom/webidl/HTMLModElement.webidl | 1 + dom/webidl/HTMLOListElement.webidl | 1 + dom/webidl/HTMLObjectElement.webidl | 2 +- dom/webidl/HTMLOptGroupElement.webidl | 1 + dom/webidl/HTMLOptionElement.webidl | 2 +- dom/webidl/HTMLOutputElement.webidl | 1 + dom/webidl/HTMLParagraphElement.webidl | 1 + dom/webidl/HTMLParamElement.webidl | 1 + dom/webidl/HTMLPictureElement.webidl | 1 + dom/webidl/HTMLPreElement.webidl | 1 + dom/webidl/HTMLProgressElement.webidl | 1 + dom/webidl/HTMLQuoteElement.webidl | 1 + dom/webidl/HTMLScriptElement.webidl | 1 + dom/webidl/HTMLSelectElement.webidl | 1 + dom/webidl/HTMLSourceElement.webidl | 1 + dom/webidl/HTMLSpanElement.webidl | 1 + dom/webidl/HTMLStyleElement.webidl | 1 + dom/webidl/HTMLTableCaptionElement.webidl | 1 + dom/webidl/HTMLTableCellElement.webidl | 1 + dom/webidl/HTMLTableColElement.webidl | 1 + dom/webidl/HTMLTableElement.webidl | 1 + dom/webidl/HTMLTableRowElement.webidl | 1 + dom/webidl/HTMLTableSectionElement.webidl | 1 + dom/webidl/HTMLTemplateElement.webidl | 1 + dom/webidl/HTMLTextAreaElement.webidl | 1 + dom/webidl/HTMLTimeElement.webidl | 1 + dom/webidl/HTMLTitleElement.webidl | 1 + dom/webidl/HTMLTrackElement.webidl | 1 + dom/webidl/HTMLUListElement.webidl | 1 + dom/webidl/HTMLVideoElement.webidl | 1 + 67 files changed, 68 insertions(+), 6 deletions(-) diff --git a/dom/webidl/HTMLAnchorElement.webidl b/dom/webidl/HTMLAnchorElement.webidl index 0b8ded6d7..aa8e7d082 100644 --- a/dom/webidl/HTMLAnchorElement.webidl +++ b/dom/webidl/HTMLAnchorElement.webidl @@ -12,6 +12,7 @@ */ // http://www.whatwg.org/specs/web-apps/current-work/#the-a-element +[HTMLConstructor] interface HTMLAnchorElement : HTMLElement { [SetterThrows] attribute DOMString target; diff --git a/dom/webidl/HTMLAreaElement.webidl b/dom/webidl/HTMLAreaElement.webidl index be3f37885..113f1822e 100644 --- a/dom/webidl/HTMLAreaElement.webidl +++ b/dom/webidl/HTMLAreaElement.webidl @@ -13,6 +13,7 @@ */ // http://www.whatwg.org/specs/web-apps/current-work/#the-area-element +[HTMLConstructor] interface HTMLAreaElement : HTMLElement { [SetterThrows] attribute DOMString alt; diff --git a/dom/webidl/HTMLAudioElement.webidl b/dom/webidl/HTMLAudioElement.webidl index 8537453c0..725669839 100644 --- a/dom/webidl/HTMLAudioElement.webidl +++ b/dom/webidl/HTMLAudioElement.webidl @@ -11,6 +11,6 @@ * and create derivative works of this document. */ -[NamedConstructor=Audio(optional DOMString src)] +[HTMLConstructor, NamedConstructor=Audio(optional DOMString src)] interface HTMLAudioElement : HTMLMediaElement {}; diff --git a/dom/webidl/HTMLBRElement.webidl b/dom/webidl/HTMLBRElement.webidl index cf5cb8a67..07b8d9f0d 100644 --- a/dom/webidl/HTMLBRElement.webidl +++ b/dom/webidl/HTMLBRElement.webidl @@ -13,6 +13,7 @@ */ // http://www.whatwg.org/specs/web-apps/current-work/#the-br-element +[HTMLConstructor] interface HTMLBRElement : HTMLElement {}; // http://www.whatwg.org/specs/web-apps/current-work/#other-elements,-attributes-and-apis diff --git a/dom/webidl/HTMLBaseElement.webidl b/dom/webidl/HTMLBaseElement.webidl index d982f4654..bc43e0570 100644 --- a/dom/webidl/HTMLBaseElement.webidl +++ b/dom/webidl/HTMLBaseElement.webidl @@ -12,6 +12,7 @@ */ // http://www.whatwg.org/specs/web-apps/current-work/#the-base-element +[HTMLConstructor] interface HTMLBaseElement : HTMLElement { [SetterThrows, Pure] attribute DOMString href; diff --git a/dom/webidl/HTMLBodyElement.webidl b/dom/webidl/HTMLBodyElement.webidl index 95df2d43a..e17758491 100644 --- a/dom/webidl/HTMLBodyElement.webidl +++ b/dom/webidl/HTMLBodyElement.webidl @@ -11,6 +11,7 @@ * and create derivative works of this document. */ +[HTMLConstructor] interface HTMLBodyElement : HTMLElement { }; diff --git a/dom/webidl/HTMLButtonElement.webidl b/dom/webidl/HTMLButtonElement.webidl index 579efa39c..5d7965cfb 100644 --- a/dom/webidl/HTMLButtonElement.webidl +++ b/dom/webidl/HTMLButtonElement.webidl @@ -11,6 +11,7 @@ */ // http://www.whatwg.org/specs/web-apps/current-work/#the-button-element +[HTMLConstructor] interface HTMLButtonElement : HTMLElement { [SetterThrows, Pure] attribute boolean autofocus; diff --git a/dom/webidl/HTMLCanvasElement.webidl b/dom/webidl/HTMLCanvasElement.webidl index 15e94f154..4a0c4499b 100644 --- a/dom/webidl/HTMLCanvasElement.webidl +++ b/dom/webidl/HTMLCanvasElement.webidl @@ -13,6 +13,7 @@ interface nsISupports; interface Variant; +[HTMLConstructor] interface HTMLCanvasElement : HTMLElement { [Pure, SetterThrows] attribute unsigned long width; diff --git a/dom/webidl/HTMLDListElement.webidl b/dom/webidl/HTMLDListElement.webidl index 08020a497..4e3fa88d8 100644 --- a/dom/webidl/HTMLDListElement.webidl +++ b/dom/webidl/HTMLDListElement.webidl @@ -13,6 +13,7 @@ */ // http://www.whatwg.org/specs/web-apps/current-work/#the-dl-element +[HTMLConstructor] interface HTMLDListElement : HTMLElement { }; diff --git a/dom/webidl/HTMLDataElement.webidl b/dom/webidl/HTMLDataElement.webidl index 821b8b483..6b9a7f19a 100644 --- a/dom/webidl/HTMLDataElement.webidl +++ b/dom/webidl/HTMLDataElement.webidl @@ -7,6 +7,7 @@ * http://www.whatwg.org/specs/web-apps/current-work/multipage/text-level-semantics.html#the-data-element */ +[HTMLConstructor] interface HTMLDataElement : HTMLElement { [SetterThrows] attribute DOMString value; diff --git a/dom/webidl/HTMLDataListElement.webidl b/dom/webidl/HTMLDataListElement.webidl index 83b20cd2b..4c38fddf3 100644 --- a/dom/webidl/HTMLDataListElement.webidl +++ b/dom/webidl/HTMLDataListElement.webidl @@ -11,6 +11,7 @@ * and create derivative works of this document. */ +[HTMLConstructor] interface HTMLDataListElement : HTMLElement { readonly attribute HTMLCollection options; }; diff --git a/dom/webidl/HTMLDetailsElement.webidl b/dom/webidl/HTMLDetailsElement.webidl index 104606eb1..f57f5c93c 100644 --- a/dom/webidl/HTMLDetailsElement.webidl +++ b/dom/webidl/HTMLDetailsElement.webidl @@ -11,6 +11,7 @@ * and create derivative works of this document. */ +[HTMLConstructor] interface HTMLDetailsElement : HTMLElement { [SetterThrows] attribute boolean open; diff --git a/dom/webidl/HTMLDirectoryElement.webidl b/dom/webidl/HTMLDirectoryElement.webidl index 9d5160af1..d50b4d330 100644 --- a/dom/webidl/HTMLDirectoryElement.webidl +++ b/dom/webidl/HTMLDirectoryElement.webidl @@ -12,6 +12,7 @@ */ // http://www.whatwg.org/specs/web-apps/current-work/#other-elements,-attributes-and-apis +[HTMLConstructor] interface HTMLDirectoryElement : HTMLElement { [SetterThrows, Pure] attribute boolean compact; diff --git a/dom/webidl/HTMLDivElement.webidl b/dom/webidl/HTMLDivElement.webidl index f50e2aad0..584c01e0e 100644 --- a/dom/webidl/HTMLDivElement.webidl +++ b/dom/webidl/HTMLDivElement.webidl @@ -11,6 +11,7 @@ * and create derivative works of this document. */ +[HTMLConstructor] interface HTMLDivElement : HTMLElement {}; partial interface HTMLDivElement { diff --git a/dom/webidl/HTMLElement.webidl b/dom/webidl/HTMLElement.webidl index 5ce5024e6..890341ec0 100644 --- a/dom/webidl/HTMLElement.webidl +++ b/dom/webidl/HTMLElement.webidl @@ -12,6 +12,7 @@ * and create derivative works of this document. */ +[HTMLConstructor] interface HTMLElement : Element { // metadata attributes attribute DOMString title; diff --git a/dom/webidl/HTMLEmbedElement.webidl b/dom/webidl/HTMLEmbedElement.webidl index 36668595b..d4e678011 100644 --- a/dom/webidl/HTMLEmbedElement.webidl +++ b/dom/webidl/HTMLEmbedElement.webidl @@ -13,7 +13,7 @@ */ // http://www.whatwg.org/specs/web-apps/current-work/#the-embed-element -[NeedResolve] +[HTMLConstructor, NeedResolve] interface HTMLEmbedElement : HTMLElement { [Pure, SetterThrows] attribute DOMString src; diff --git a/dom/webidl/HTMLFieldSetElement.webidl b/dom/webidl/HTMLFieldSetElement.webidl index 6c9eee52b..f61cdbf5b 100644 --- a/dom/webidl/HTMLFieldSetElement.webidl +++ b/dom/webidl/HTMLFieldSetElement.webidl @@ -11,6 +11,7 @@ * and create derivative works of this document. */ +[HTMLConstructor] interface HTMLFieldSetElement : HTMLElement { [SetterThrows] attribute boolean disabled; diff --git a/dom/webidl/HTMLFontElement.webidl b/dom/webidl/HTMLFontElement.webidl index 781dabb88..09c0eae9b 100644 --- a/dom/webidl/HTMLFontElement.webidl +++ b/dom/webidl/HTMLFontElement.webidl @@ -11,6 +11,7 @@ * and create derivative works of this document. */ +[HTMLConstructor] interface HTMLFontElement : HTMLElement { [TreatNullAs=EmptyString, SetterThrows] attribute DOMString color; [SetterThrows] attribute DOMString face; diff --git a/dom/webidl/HTMLFormElement.webidl b/dom/webidl/HTMLFormElement.webidl index 8d248e1a5..dcc909483 100644 --- a/dom/webidl/HTMLFormElement.webidl +++ b/dom/webidl/HTMLFormElement.webidl @@ -11,7 +11,7 @@ * and create derivative works of this document. */ -[OverrideBuiltins, LegacyUnenumerableNamedProperties] +[OverrideBuiltins, LegacyUnenumerableNamedProperties, HTMLConstructor] interface HTMLFormElement : HTMLElement { [Pure, SetterThrows] attribute DOMString acceptCharset; diff --git a/dom/webidl/HTMLFrameElement.webidl b/dom/webidl/HTMLFrameElement.webidl index 9c5aca7c4..e7d702143 100644 --- a/dom/webidl/HTMLFrameElement.webidl +++ b/dom/webidl/HTMLFrameElement.webidl @@ -11,6 +11,7 @@ */ // http://www.whatwg.org/specs/web-apps/current-work/#htmlframeelement +[HTMLConstructor] interface HTMLFrameElement : HTMLElement { [SetterThrows] attribute DOMString name; diff --git a/dom/webidl/HTMLFrameSetElement.webidl b/dom/webidl/HTMLFrameSetElement.webidl index ce00d487f..cf4e34bcf 100644 --- a/dom/webidl/HTMLFrameSetElement.webidl +++ b/dom/webidl/HTMLFrameSetElement.webidl @@ -11,6 +11,7 @@ * and create derivative works of this document. */ +[HTMLConstructor] interface HTMLFrameSetElement : HTMLElement { [SetterThrows] attribute DOMString cols; diff --git a/dom/webidl/HTMLHRElement.webidl b/dom/webidl/HTMLHRElement.webidl index 0495e43b3..9359d74b9 100644 --- a/dom/webidl/HTMLHRElement.webidl +++ b/dom/webidl/HTMLHRElement.webidl @@ -12,6 +12,7 @@ */ // http://www.whatwg.org/specs/web-apps/current-work/#the-hr-element +[HTMLConstructor] interface HTMLHRElement : HTMLElement { }; diff --git a/dom/webidl/HTMLHeadElement.webidl b/dom/webidl/HTMLHeadElement.webidl index 0ad45e384..b649712a6 100644 --- a/dom/webidl/HTMLHeadElement.webidl +++ b/dom/webidl/HTMLHeadElement.webidl @@ -12,5 +12,6 @@ */ // http://www.whatwg.org/specs/web-apps/current-work/#the-head-element +[HTMLConstructor] interface HTMLHeadElement : HTMLElement {}; diff --git a/dom/webidl/HTMLHeadingElement.webidl b/dom/webidl/HTMLHeadingElement.webidl index c07e5cb99..97e471025 100644 --- a/dom/webidl/HTMLHeadingElement.webidl +++ b/dom/webidl/HTMLHeadingElement.webidl @@ -12,6 +12,7 @@ */ // http://www.whatwg.org/specs/web-apps/current-work/#the-h1,-h2,-h3,-h4,-h5,-and-h6-elements +[HTMLConstructor] interface HTMLHeadingElement : HTMLElement { }; diff --git a/dom/webidl/HTMLHtmlElement.webidl b/dom/webidl/HTMLHtmlElement.webidl index b06de7761..f9174a185 100644 --- a/dom/webidl/HTMLHtmlElement.webidl +++ b/dom/webidl/HTMLHtmlElement.webidl @@ -13,6 +13,7 @@ */ // http://www.whatwg.org/specs/web-apps/current-work/#the-html-element +[HTMLConstructor] interface HTMLHtmlElement : HTMLElement {}; // http://www.whatwg.org/specs/web-apps/current-work/#other-elements,-attributes-and-apis diff --git a/dom/webidl/HTMLIFrameElement.webidl b/dom/webidl/HTMLIFrameElement.webidl index 0a1b49aff..4b9d1ce4c 100644 --- a/dom/webidl/HTMLIFrameElement.webidl +++ b/dom/webidl/HTMLIFrameElement.webidl @@ -11,6 +11,7 @@ * and create derivative works of this document. */ +[HTMLConstructor] interface HTMLIFrameElement : HTMLElement { [SetterThrows, Pure] attribute DOMString src; diff --git a/dom/webidl/HTMLImageElement.webidl b/dom/webidl/HTMLImageElement.webidl index 243c65509..c6bc3e4c8 100644 --- a/dom/webidl/HTMLImageElement.webidl +++ b/dom/webidl/HTMLImageElement.webidl @@ -16,7 +16,8 @@ interface imgIRequest; interface URI; interface nsIStreamListener; -[NamedConstructor=Image(optional unsigned long width, optional unsigned long height)] +[HTMLConstructor, + NamedConstructor=Image(optional unsigned long width, optional unsigned long height)] interface HTMLImageElement : HTMLElement { [SetterThrows] attribute DOMString alt; diff --git a/dom/webidl/HTMLInputElement.webidl b/dom/webidl/HTMLInputElement.webidl index cf3e9a4c7..deb5b5faf 100644 --- a/dom/webidl/HTMLInputElement.webidl +++ b/dom/webidl/HTMLInputElement.webidl @@ -21,6 +21,7 @@ enum SelectionMode { interface nsIControllers; +[HTMLConstructor] interface HTMLInputElement : HTMLElement { [Pure, SetterThrows] attribute DOMString accept; diff --git a/dom/webidl/HTMLLIElement.webidl b/dom/webidl/HTMLLIElement.webidl index c20e00846..d36b96a0f 100644 --- a/dom/webidl/HTMLLIElement.webidl +++ b/dom/webidl/HTMLLIElement.webidl @@ -13,6 +13,7 @@ */ // http://www.whatwg.org/specs/web-apps/current-work/#the-li-element +[HTMLConstructor] interface HTMLLIElement : HTMLElement { [SetterThrows, Pure] attribute long value; diff --git a/dom/webidl/HTMLLabelElement.webidl b/dom/webidl/HTMLLabelElement.webidl index f44a56219..8a5c67fbc 100644 --- a/dom/webidl/HTMLLabelElement.webidl +++ b/dom/webidl/HTMLLabelElement.webidl @@ -11,6 +11,7 @@ * and create derivative works of this document. */ +[HTMLConstructor] interface HTMLLabelElement : HTMLElement { readonly attribute HTMLFormElement? form; attribute DOMString htmlFor; diff --git a/dom/webidl/HTMLLegendElement.webidl b/dom/webidl/HTMLLegendElement.webidl index 0ce4ae88b..8feb70dcb 100644 --- a/dom/webidl/HTMLLegendElement.webidl +++ b/dom/webidl/HTMLLegendElement.webidl @@ -13,6 +13,7 @@ */ // http://www.whatwg.org/specs/web-apps/current-work/#the-legend-element +[HTMLConstructor] interface HTMLLegendElement : HTMLElement { readonly attribute HTMLFormElement? form; }; diff --git a/dom/webidl/HTMLLinkElement.webidl b/dom/webidl/HTMLLinkElement.webidl index ec094e55e..c5d8eec4f 100644 --- a/dom/webidl/HTMLLinkElement.webidl +++ b/dom/webidl/HTMLLinkElement.webidl @@ -12,6 +12,7 @@ */ // http://www.whatwg.org/specs/web-apps/current-work/#the-link-element +[HTMLConstructor] interface HTMLLinkElement : HTMLElement { [Pure] attribute boolean disabled; diff --git a/dom/webidl/HTMLMapElement.webidl b/dom/webidl/HTMLMapElement.webidl index 88fe4e54c..cf4d40426 100644 --- a/dom/webidl/HTMLMapElement.webidl +++ b/dom/webidl/HTMLMapElement.webidl @@ -11,6 +11,7 @@ */ // http://www.whatwg.org/specs/web-apps/current-work/#the-map-element +[HTMLConstructor] interface HTMLMapElement : HTMLElement { [SetterThrows, Pure] attribute DOMString name; diff --git a/dom/webidl/HTMLMenuElement.webidl b/dom/webidl/HTMLMenuElement.webidl index ff81a7c80..7658d8380 100644 --- a/dom/webidl/HTMLMenuElement.webidl +++ b/dom/webidl/HTMLMenuElement.webidl @@ -15,6 +15,7 @@ interface MenuBuilder; // http://www.whatwg.org/specs/web-apps/current-work/#the-menu-element +[HTMLConstructor] interface HTMLMenuElement : HTMLElement { [SetterThrows] attribute DOMString type; diff --git a/dom/webidl/HTMLMenuItemElement.webidl b/dom/webidl/HTMLMenuItemElement.webidl index 7064885a1..1a7750483 100644 --- a/dom/webidl/HTMLMenuItemElement.webidl +++ b/dom/webidl/HTMLMenuItemElement.webidl @@ -12,6 +12,7 @@ */ // http://www.whatwg.org/specs/web-apps/current-work/#the-menuitem-element +[HTMLConstructor] interface HTMLMenuItemElement : HTMLElement { [SetterThrows] attribute DOMString type; diff --git a/dom/webidl/HTMLMetaElement.webidl b/dom/webidl/HTMLMetaElement.webidl index 5b7b0f92c..171f67305 100644 --- a/dom/webidl/HTMLMetaElement.webidl +++ b/dom/webidl/HTMLMetaElement.webidl @@ -12,6 +12,7 @@ */ // http://www.whatwg.org/specs/web-apps/current-work/#the-meta-element +[HTMLConstructor] interface HTMLMetaElement : HTMLElement { [SetterThrows, Pure] attribute DOMString name; diff --git a/dom/webidl/HTMLMeterElement.webidl b/dom/webidl/HTMLMeterElement.webidl index 104e00353..484ece85c 100644 --- a/dom/webidl/HTMLMeterElement.webidl +++ b/dom/webidl/HTMLMeterElement.webidl @@ -12,6 +12,7 @@ */ // http://www.whatwg.org/specs/web-apps/current-work/#the-meter-element +[HTMLConstructor] interface HTMLMeterElement : HTMLElement { [SetterThrows] attribute double value; diff --git a/dom/webidl/HTMLModElement.webidl b/dom/webidl/HTMLModElement.webidl index 45086cceb..654aca272 100644 --- a/dom/webidl/HTMLModElement.webidl +++ b/dom/webidl/HTMLModElement.webidl @@ -11,6 +11,7 @@ */ // http://www.whatwg.org/specs/web-apps/current-work/#attributes-common-to-ins-and-del-elements +[HTMLConstructor] interface HTMLModElement : HTMLElement { [SetterThrows, Pure] attribute DOMString cite; diff --git a/dom/webidl/HTMLOListElement.webidl b/dom/webidl/HTMLOListElement.webidl index f41abf3ea..5b10d4807 100644 --- a/dom/webidl/HTMLOListElement.webidl +++ b/dom/webidl/HTMLOListElement.webidl @@ -13,6 +13,7 @@ */ // http://www.whatwg.org/specs/web-apps/current-work/#the-ol-element +[HTMLConstructor] interface HTMLOListElement : HTMLElement { [SetterThrows] attribute boolean reversed; diff --git a/dom/webidl/HTMLObjectElement.webidl b/dom/webidl/HTMLObjectElement.webidl index ebb95ab09..797b04119 100644 --- a/dom/webidl/HTMLObjectElement.webidl +++ b/dom/webidl/HTMLObjectElement.webidl @@ -13,7 +13,7 @@ */ // http://www.whatwg.org/specs/web-apps/current-work/#the-object-element -[NeedResolve, UnsafeInPrerendering] +[HTMLConstructor, NeedResolve, UnsafeInPrerendering] interface HTMLObjectElement : HTMLElement { [Pure, SetterThrows] attribute DOMString data; diff --git a/dom/webidl/HTMLOptGroupElement.webidl b/dom/webidl/HTMLOptGroupElement.webidl index a23aee30d..18d2e5dfa 100644 --- a/dom/webidl/HTMLOptGroupElement.webidl +++ b/dom/webidl/HTMLOptGroupElement.webidl @@ -11,6 +11,7 @@ * and create derivative works of this document. */ +[HTMLConstructor] interface HTMLOptGroupElement : HTMLElement { [SetterThrows] attribute boolean disabled; diff --git a/dom/webidl/HTMLOptionElement.webidl b/dom/webidl/HTMLOptionElement.webidl index c80bedeef..34e6e6c23 100644 --- a/dom/webidl/HTMLOptionElement.webidl +++ b/dom/webidl/HTMLOptionElement.webidl @@ -11,7 +11,7 @@ * and create derivative works of this document. */ -[NamedConstructor=Option(optional DOMString text, optional DOMString value, optional boolean defaultSelected, optional boolean selected)] +[HTMLConstructor, NamedConstructor=Option(optional DOMString text, optional DOMString value, optional boolean defaultSelected, optional boolean selected)] interface HTMLOptionElement : HTMLElement { [SetterThrows] attribute boolean disabled; diff --git a/dom/webidl/HTMLOutputElement.webidl b/dom/webidl/HTMLOutputElement.webidl index d0e4ecbe6..698fd08d1 100644 --- a/dom/webidl/HTMLOutputElement.webidl +++ b/dom/webidl/HTMLOutputElement.webidl @@ -12,6 +12,7 @@ */ // http://www.whatwg.org/specs/web-apps/current-work/#the-output-element +[HTMLConstructor] interface HTMLOutputElement : HTMLElement { [PutForwards=value, Constant] readonly attribute DOMTokenList htmlFor; diff --git a/dom/webidl/HTMLParagraphElement.webidl b/dom/webidl/HTMLParagraphElement.webidl index 2a626d257..b72f627d1 100644 --- a/dom/webidl/HTMLParagraphElement.webidl +++ b/dom/webidl/HTMLParagraphElement.webidl @@ -12,6 +12,7 @@ */ // http://www.whatwg.org/specs/web-apps/current-work/#the-p-element +[HTMLConstructor] interface HTMLParagraphElement : HTMLElement { }; diff --git a/dom/webidl/HTMLParamElement.webidl b/dom/webidl/HTMLParamElement.webidl index e2c7e8d7f..b9f17d6f5 100644 --- a/dom/webidl/HTMLParamElement.webidl +++ b/dom/webidl/HTMLParamElement.webidl @@ -13,6 +13,7 @@ */ // http://www.whatwg.org/specs/web-apps/current-work/#the-param-element +[HTMLConstructor] interface HTMLParamElement : HTMLElement { [SetterThrows, Pure] attribute DOMString name; diff --git a/dom/webidl/HTMLPictureElement.webidl b/dom/webidl/HTMLPictureElement.webidl index eff30f750..387eee78d 100644 --- a/dom/webidl/HTMLPictureElement.webidl +++ b/dom/webidl/HTMLPictureElement.webidl @@ -4,5 +4,6 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ +[HTMLConstructor] interface HTMLPictureElement : HTMLElement { }; diff --git a/dom/webidl/HTMLPreElement.webidl b/dom/webidl/HTMLPreElement.webidl index db220b74c..b128e824d 100644 --- a/dom/webidl/HTMLPreElement.webidl +++ b/dom/webidl/HTMLPreElement.webidl @@ -12,6 +12,7 @@ */ // http://www.whatwg.org/specs/web-apps/current-work/#the-pre-element +[HTMLConstructor] interface HTMLPreElement : HTMLElement { }; diff --git a/dom/webidl/HTMLProgressElement.webidl b/dom/webidl/HTMLProgressElement.webidl index 028728e22..5729829cd 100644 --- a/dom/webidl/HTMLProgressElement.webidl +++ b/dom/webidl/HTMLProgressElement.webidl @@ -11,6 +11,7 @@ * and create derivative works of this document. */ +[HTMLConstructor] interface HTMLProgressElement : HTMLElement { [SetterThrows] attribute double value; diff --git a/dom/webidl/HTMLQuoteElement.webidl b/dom/webidl/HTMLQuoteElement.webidl index a266dd353..5cf9c4c29 100644 --- a/dom/webidl/HTMLQuoteElement.webidl +++ b/dom/webidl/HTMLQuoteElement.webidl @@ -12,6 +12,7 @@ */ // http://www.whatwg.org/specs/web-apps/current-work/#the-blockquote-element +[HTMLConstructor] interface HTMLQuoteElement : HTMLElement { [SetterThrows, Pure] attribute DOMString cite; diff --git a/dom/webidl/HTMLScriptElement.webidl b/dom/webidl/HTMLScriptElement.webidl index 5b64c42d7..8bcffe8d7 100644 --- a/dom/webidl/HTMLScriptElement.webidl +++ b/dom/webidl/HTMLScriptElement.webidl @@ -8,6 +8,7 @@ * http://www.whatwg.org/specs/web-apps/current-work/#other-elements,-attributes-and-apis */ +[HTMLConstructor] interface HTMLScriptElement : HTMLElement { [SetterThrows] attribute DOMString src; diff --git a/dom/webidl/HTMLSelectElement.webidl b/dom/webidl/HTMLSelectElement.webidl index b18ca3634..9a9b33040 100644 --- a/dom/webidl/HTMLSelectElement.webidl +++ b/dom/webidl/HTMLSelectElement.webidl @@ -7,6 +7,7 @@ * http://www.whatwg.org/html/#the-select-element */ +[HTMLConstructor] interface HTMLSelectElement : HTMLElement { [SetterThrows, Pure] attribute boolean autofocus; diff --git a/dom/webidl/HTMLSourceElement.webidl b/dom/webidl/HTMLSourceElement.webidl index 10b8e6fd5..402b4491a 100644 --- a/dom/webidl/HTMLSourceElement.webidl +++ b/dom/webidl/HTMLSourceElement.webidl @@ -11,6 +11,7 @@ * and create derivative works of this document. */ +[HTMLConstructor] interface HTMLSourceElement : HTMLElement { [SetterThrows] attribute DOMString src; diff --git a/dom/webidl/HTMLSpanElement.webidl b/dom/webidl/HTMLSpanElement.webidl index 43a2d97f2..6f65cdfb3 100644 --- a/dom/webidl/HTMLSpanElement.webidl +++ b/dom/webidl/HTMLSpanElement.webidl @@ -12,4 +12,5 @@ */ // http://www.whatwg.org/specs/web-apps/current-work/#the-span-element +[HTMLConstructor] interface HTMLSpanElement : HTMLElement {}; diff --git a/dom/webidl/HTMLStyleElement.webidl b/dom/webidl/HTMLStyleElement.webidl index 7ed01a8f1..b547d6976 100644 --- a/dom/webidl/HTMLStyleElement.webidl +++ b/dom/webidl/HTMLStyleElement.webidl @@ -8,6 +8,7 @@ * http://www.whatwg.org/specs/web-apps/current-work/#other-elements,-attributes-and-apis */ +[HTMLConstructor] interface HTMLStyleElement : HTMLElement { [Pure] attribute boolean disabled; diff --git a/dom/webidl/HTMLTableCaptionElement.webidl b/dom/webidl/HTMLTableCaptionElement.webidl index 688b9f925..e9d01527e 100644 --- a/dom/webidl/HTMLTableCaptionElement.webidl +++ b/dom/webidl/HTMLTableCaptionElement.webidl @@ -11,6 +11,7 @@ * and create derivative works of this document. */ +[HTMLConstructor] interface HTMLTableCaptionElement : HTMLElement {}; partial interface HTMLTableCaptionElement { diff --git a/dom/webidl/HTMLTableCellElement.webidl b/dom/webidl/HTMLTableCellElement.webidl index e970a5040..f0a251d27 100644 --- a/dom/webidl/HTMLTableCellElement.webidl +++ b/dom/webidl/HTMLTableCellElement.webidl @@ -11,6 +11,7 @@ * and create derivative works of this document. */ +[HTMLConstructor] interface HTMLTableCellElement : HTMLElement { [SetterThrows] attribute unsigned long colSpan; diff --git a/dom/webidl/HTMLTableColElement.webidl b/dom/webidl/HTMLTableColElement.webidl index c927541a3..cf217548a 100644 --- a/dom/webidl/HTMLTableColElement.webidl +++ b/dom/webidl/HTMLTableColElement.webidl @@ -11,6 +11,7 @@ * and create derivative works of this document. */ +[HTMLConstructor] interface HTMLTableColElement : HTMLElement { [SetterThrows] attribute unsigned long span; diff --git a/dom/webidl/HTMLTableElement.webidl b/dom/webidl/HTMLTableElement.webidl index a06f590e0..2653524d6 100644 --- a/dom/webidl/HTMLTableElement.webidl +++ b/dom/webidl/HTMLTableElement.webidl @@ -11,6 +11,7 @@ * and create derivative works of this document. */ +[HTMLConstructor] interface HTMLTableElement : HTMLElement { [SetterThrows] attribute HTMLTableCaptionElement? caption; diff --git a/dom/webidl/HTMLTableRowElement.webidl b/dom/webidl/HTMLTableRowElement.webidl index 2a356a20e..7d63bcc04 100644 --- a/dom/webidl/HTMLTableRowElement.webidl +++ b/dom/webidl/HTMLTableRowElement.webidl @@ -11,6 +11,7 @@ * and create derivative works of this document. */ +[HTMLConstructor] interface HTMLTableRowElement : HTMLElement { readonly attribute long rowIndex; readonly attribute long sectionRowIndex; diff --git a/dom/webidl/HTMLTableSectionElement.webidl b/dom/webidl/HTMLTableSectionElement.webidl index 310d0ece6..881972ac2 100644 --- a/dom/webidl/HTMLTableSectionElement.webidl +++ b/dom/webidl/HTMLTableSectionElement.webidl @@ -11,6 +11,7 @@ * and create derivative works of this document. */ +[HTMLConstructor] interface HTMLTableSectionElement : HTMLElement { readonly attribute HTMLCollection rows; [Throws] diff --git a/dom/webidl/HTMLTemplateElement.webidl b/dom/webidl/HTMLTemplateElement.webidl index c518995f6..f77eeaa42 100644 --- a/dom/webidl/HTMLTemplateElement.webidl +++ b/dom/webidl/HTMLTemplateElement.webidl @@ -9,6 +9,7 @@ * liability, trademark and document use rules apply. */ +[HTMLConstructor] interface HTMLTemplateElement : HTMLElement { readonly attribute DocumentFragment content; }; diff --git a/dom/webidl/HTMLTextAreaElement.webidl b/dom/webidl/HTMLTextAreaElement.webidl index 4df687a0b..8c5dc0fb9 100644 --- a/dom/webidl/HTMLTextAreaElement.webidl +++ b/dom/webidl/HTMLTextAreaElement.webidl @@ -14,6 +14,7 @@ interface nsIEditor; interface MozControllers; +[HTMLConstructor] interface HTMLTextAreaElement : HTMLElement { // attribute DOMString autocomplete; [SetterThrows, Pure] diff --git a/dom/webidl/HTMLTimeElement.webidl b/dom/webidl/HTMLTimeElement.webidl index 517ca9981..ea37405bf 100644 --- a/dom/webidl/HTMLTimeElement.webidl +++ b/dom/webidl/HTMLTimeElement.webidl @@ -7,6 +7,7 @@ * http://www.whatwg.org/specs/web-apps/current-work/multipage/text-level-semantics.html#the-time-element */ +[HTMLConstructor] interface HTMLTimeElement : HTMLElement { [SetterThrows] attribute DOMString dateTime; diff --git a/dom/webidl/HTMLTitleElement.webidl b/dom/webidl/HTMLTitleElement.webidl index e6c8f2c61..c8fe3e46a 100644 --- a/dom/webidl/HTMLTitleElement.webidl +++ b/dom/webidl/HTMLTitleElement.webidl @@ -7,6 +7,7 @@ * http://www.whatwg.org/specs/web-apps/current-work/#the-title-element */ +[HTMLConstructor] interface HTMLTitleElement : HTMLElement { [Throws] attribute DOMString text; diff --git a/dom/webidl/HTMLTrackElement.webidl b/dom/webidl/HTMLTrackElement.webidl index dd88e9beb..e6d366f10 100644 --- a/dom/webidl/HTMLTrackElement.webidl +++ b/dom/webidl/HTMLTrackElement.webidl @@ -7,6 +7,7 @@ * http://www.whatwg.org/specs/web-apps/current-work/#the-track-element */ +[HTMLConstructor] interface HTMLTrackElement : HTMLElement { [SetterThrows, Pure] attribute DOMString kind; diff --git a/dom/webidl/HTMLUListElement.webidl b/dom/webidl/HTMLUListElement.webidl index 0528198c9..01ca7afce 100644 --- a/dom/webidl/HTMLUListElement.webidl +++ b/dom/webidl/HTMLUListElement.webidl @@ -13,6 +13,7 @@ */ // http://www.whatwg.org/specs/web-apps/current-work/#the-ul-element +[HTMLConstructor] interface HTMLUListElement : HTMLElement { }; diff --git a/dom/webidl/HTMLVideoElement.webidl b/dom/webidl/HTMLVideoElement.webidl index af28d5418..fd552f7e0 100644 --- a/dom/webidl/HTMLVideoElement.webidl +++ b/dom/webidl/HTMLVideoElement.webidl @@ -11,6 +11,7 @@ * and create derivative works of this document. */ +[HTMLConstructor] interface HTMLVideoElement : HTMLMediaElement { [SetterThrows] attribute unsigned long width; -- cgit v1.2.3 From 5b814fffd697bf16a4ac0a1242547b175b969411 Mon Sep 17 00:00:00 2001 From: Gaming4JC Date: Thu, 2 Jan 2020 21:47:43 -0500 Subject: Bug 1274159 - Part 3-2: Update web-platform-test expected result; Tag UXP Issue #1344 --- .../meta/custom-elements/CustomElementRegistry.html.ini | 3 --- .../meta/custom-elements/HTMLElement-constructor.html.ini | 11 ----------- .../custom-elements/htmlconstructor/newtarget.html.ini | 14 -------------- 3 files changed, 28 deletions(-) delete mode 100644 testing/web-platform/meta/custom-elements/HTMLElement-constructor.html.ini delete mode 100644 testing/web-platform/meta/custom-elements/htmlconstructor/newtarget.html.ini diff --git a/testing/web-platform/meta/custom-elements/CustomElementRegistry.html.ini b/testing/web-platform/meta/custom-elements/CustomElementRegistry.html.ini index f62b64dfb..29be90bea 100644 --- a/testing/web-platform/meta/custom-elements/CustomElementRegistry.html.ini +++ b/testing/web-platform/meta/custom-elements/CustomElementRegistry.html.ini @@ -18,9 +18,6 @@ [customElements.define must rethrow an exception thrown while retrieving Symbol.iterator on observedAttributes] expected: FAIL - [customElements.define must define an instantiatable custom element] - expected: FAIL - [customElements.define must upgrade elements in the shadow-including tree order] expected: FAIL diff --git a/testing/web-platform/meta/custom-elements/HTMLElement-constructor.html.ini b/testing/web-platform/meta/custom-elements/HTMLElement-constructor.html.ini deleted file mode 100644 index 0d2d4374f..000000000 --- a/testing/web-platform/meta/custom-elements/HTMLElement-constructor.html.ini +++ /dev/null @@ -1,11 +0,0 @@ -[HTMLElement-constructor.html] - type: testharness - [HTMLElement constructor must infer the tag name from the element interface] - expected: FAIL - - [HTMLElement constructor must allow subclassing a custom element] - expected: FAIL - - [HTMLElement constructor must allow subclassing an user-defined subclass of HTMLElement] - expected: FAIL - diff --git a/testing/web-platform/meta/custom-elements/htmlconstructor/newtarget.html.ini b/testing/web-platform/meta/custom-elements/htmlconstructor/newtarget.html.ini deleted file mode 100644 index f77a64e1d..000000000 --- a/testing/web-platform/meta/custom-elements/htmlconstructor/newtarget.html.ini +++ /dev/null @@ -1,14 +0,0 @@ -[newtarget.html] - type: testharness - [Use NewTarget's prototype, not the one stored at definition time] - expected: FAIL - - [Rethrow any exceptions thrown while getting the prototype] - expected: FAIL - - [If prototype is not object, derives the fallback from NewTarget's realm (autonomous custom elements)] - expected: FAIL - - [If prototype is not object, derives the fallback from NewTarget's realm (customized built-in elements)] - expected: FAIL - -- cgit v1.2.3 From bac01e30fda6b9efc6a6545cbb982ec87ac9f2e9 Mon Sep 17 00:00:00 2001 From: Gaming4JC Date: Thu, 2 Jan 2020 21:48:12 -0500 Subject: Bug 1274159 - Part 4: Add test cases for HTMLConstructor; Tag UXP Issue #1344 --- dom/tests/mochitest/webcomponents/chrome.ini | 9 + dom/tests/mochitest/webcomponents/dummy_page.html | 10 + .../htmlconstructor_autonomous_tests.js | 81 +++++++ .../webcomponents/htmlconstructor_builtin_tests.js | 247 +++++++++++++++++++++ dom/tests/mochitest/webcomponents/mochitest.ini | 6 + .../test_custom_element_htmlconstructor.html | 42 ++++ ...test_custom_element_htmlconstructor_chrome.html | 41 ++++ dom/tests/moz.build | 1 + 8 files changed, 437 insertions(+) create mode 100644 dom/tests/mochitest/webcomponents/chrome.ini create mode 100644 dom/tests/mochitest/webcomponents/dummy_page.html create mode 100644 dom/tests/mochitest/webcomponents/htmlconstructor_autonomous_tests.js create mode 100644 dom/tests/mochitest/webcomponents/htmlconstructor_builtin_tests.js create mode 100644 dom/tests/mochitest/webcomponents/test_custom_element_htmlconstructor.html create mode 100644 dom/tests/mochitest/webcomponents/test_custom_element_htmlconstructor_chrome.html diff --git a/dom/tests/mochitest/webcomponents/chrome.ini b/dom/tests/mochitest/webcomponents/chrome.ini new file mode 100644 index 000000000..5e25c2123 --- /dev/null +++ b/dom/tests/mochitest/webcomponents/chrome.ini @@ -0,0 +1,9 @@ +[DEFAULT] +support-files = + dummy_page.html + +[test_custom_element_htmlconstructor_chrome.html] +skip-if = os == 'android' # bug 1323645 +support-files = + htmlconstructor_autonomous_tests.js + htmlconstructor_builtin_tests.js diff --git a/dom/tests/mochitest/webcomponents/dummy_page.html b/dom/tests/mochitest/webcomponents/dummy_page.html new file mode 100644 index 000000000..fd238954c --- /dev/null +++ b/dom/tests/mochitest/webcomponents/dummy_page.html @@ -0,0 +1,10 @@ + + + +Dummy test page + + + +

Dummy test page

+ + diff --git a/dom/tests/mochitest/webcomponents/htmlconstructor_autonomous_tests.js b/dom/tests/mochitest/webcomponents/htmlconstructor_autonomous_tests.js new file mode 100644 index 000000000..636d9aff6 --- /dev/null +++ b/dom/tests/mochitest/webcomponents/htmlconstructor_autonomous_tests.js @@ -0,0 +1,81 @@ +promises.push(test_with_new_window((testWindow) => { + // Test calling the HTMLElement constructor. + (() => { + SimpleTest.doesThrow(() => { + testWindow.HTMLElement(); + }, 'calling the HTMLElement constructor should throw a TypeError'); + })(); + + // Test constructing a HTMLELement. + (() => { + SimpleTest.doesThrow(() => { + new testWindow.HTMLElement(); + }, 'constructing a HTMLElement should throw a TypeError'); + })(); + + // Test constructing a custom element with defining HTMLElement as entry. + (() => { + testWindow.customElements.define('x-defining-html-element', + testWindow.HTMLElement); + SimpleTest.doesThrow(() => { + new testWindow.HTMLElement(); + }, 'constructing a custom element with defining HTMLElement as registry ' + + 'entry should throw a TypeError'); + })(); + + // Test calling a custom element constructor and constructing an autonomous + // custom element. + (() => { + let num_constructor_invocations = 0; + class X extends testWindow.HTMLElement { + constructor() { + super(); + num_constructor_invocations++; + } + } + testWindow.customElements.define('x-element', X); + SimpleTest.doesThrow(() => { + X(); + }, 'calling an autonomous custom element constructor should throw a TypeError'); + + let element = new X(); + SimpleTest.is(Object.getPrototypeOf(Cu.waiveXrays(element)), X.prototype, + 'constructing an autonomous custom element; ' + + 'the element should be a registered constructor'); + SimpleTest.is(element.localName, 'x-element', + 'constructing an autonomous custom element; ' + + 'the element tag name should be "x-element"'); + SimpleTest.is(element.namespaceURI, 'http://www.w3.org/1999/xhtml', + 'constructing an autonomous custom element; ' + + 'the element should be in the HTML namespace'); + SimpleTest.is(element.prefix, null, + 'constructing an autonomous custom element; ' + + 'the element name should not have a prefix'); + SimpleTest.is(element.ownerDocument, testWindow.document, + 'constructing an autonomous custom element; ' + + 'the element should be owned by the registry\'s associated ' + + 'document'); + SimpleTest.is(num_constructor_invocations, 1, + 'constructing an autonomous custom element; ' + + 'the constructor should have been invoked once'); + })(); + + // Test if prototype is no an object. + (() => { + function ElementWithNonObjectPrototype() { + let o = Reflect.construct(testWindow.HTMLElement, [], new.target); + SimpleTest.is(Object.getPrototypeOf(Cu.waiveXrays(o)), window.HTMLElement.prototype, + 'constructing an autonomous custom element; ' + + 'if prototype is not object, fallback from NewTarget\'s realm'); + } + + // Prototype have to be an object during define(), otherwise define will + // throw an TypeError exception. + ElementWithNonObjectPrototype.prototype = {}; + testWindow.customElements.define('x-non-object-prototype', + ElementWithNonObjectPrototype); + + ElementWithNonObjectPrototype.prototype = "string"; + new ElementWithNonObjectPrototype(); + })(); +})); diff --git a/dom/tests/mochitest/webcomponents/htmlconstructor_builtin_tests.js b/dom/tests/mochitest/webcomponents/htmlconstructor_builtin_tests.js new file mode 100644 index 000000000..dd6515148 --- /dev/null +++ b/dom/tests/mochitest/webcomponents/htmlconstructor_builtin_tests.js @@ -0,0 +1,247 @@ +[ + // [TagName, InterfaceName] + ['a', 'Anchor'], + ['abbr', ''], + ['acronym', ''], + ['address', ''], + ['area', 'Area'], + ['article', ''], + ['aside', ''], + ['audio', 'Audio'], + ['b', ''], + ['base', 'Base'], + ['basefont', ''], + ['bdo', ''], + ['big', ''], + ['blockquote', 'Quote'], + ['body', 'Body'], + ['br', 'BR'], + ['button', 'Button'], + ['canvas', 'Canvas'], + ['caption', 'TableCaption'], + ['center', ''], + ['cite', ''], + ['code', ''], + ['col', 'TableCol'], + ['colgroup', 'TableCol'], + ['data', 'Data'], + ['datalist', 'DataList'], + ['dd', ''], + ['del', 'Mod'], + ['details', 'Details'], + ['dfn', ''], + ['dir', 'Directory'], + ['div', 'Div'], + ['dl', 'DList'], + ['dt', ''], + ['em', ''], + ['embed', 'Embed'], + ['fieldset', 'FieldSet'], + ['figcaption', ''], + ['figure', ''], + ['font', 'Font'], + ['footer', ''], + ['form', 'Form'], + ['frame', 'Frame'], + ['frameset', 'FrameSet'], + ['h1', 'Heading'], + ['h2', 'Heading'], + ['h3', 'Heading'], + ['h4', 'Heading'], + ['h5', 'Heading'], + ['h6', 'Heading'], + ['head', 'Head'], + ['header', ''], + ['hgroup', ''], + ['hr', 'HR'], + ['html', 'Html'], + ['i', ''], + ['iframe', 'IFrame'], + ['image', ''], + ['img', 'Image'], + ['input', 'Input'], + ['ins', 'Mod'], + ['kbd', ''], + ['label', 'Label'], + ['legend', 'Legend'], + ['li', 'LI'], + ['link', 'Link'], + ['listing', 'Pre'], + ['main', ''], + ['map', 'Map'], + ['mark', ''], + ['marquee', 'Div'], + ['menu', 'Menu'], + ['menuitem', 'MenuItem'], + ['meta', 'Meta'], + ['meter', 'Meter'], + ['nav', ''], + ['nobr', ''], + ['noembed', ''], + ['noframes', ''], + ['noscript', ''], + ['object', 'Object'], + ['ol', 'OList'], + ['optgroup', 'OptGroup'], + ['option', 'Option'], + ['output', 'Output'], + ['p', 'Paragraph'], + ['param', 'Param'], + ['picture', 'Picture'], + ['plaintext', ''], + ['pre', 'Pre'], + ['progress', 'Progress'], + ['q', 'Quote'], + ['rb', ''], + ['rp', ''], + ['rt', ''], + ['rtc', ''], + ['ruby', ''], + ['s', ''], + ['samp', ''], + ['script', 'Script'], + ['section', ''], + ['select', 'Select'], + ['small', ''], + ['source', 'Source'], + ['span', 'Span'], + ['strike', ''], + ['strong', ''], + ['style', 'Style'], + ['sub', ''], + ['summary', ''], + ['sup', ''], + ['table', 'Table'], + ['tbody', 'TableSection'], + ['td', 'TableCell'], + ['textarea', 'TextArea'], + ['tfoot', 'TableSection'], + ['th', 'TableCell'], + ['thead', 'TableSection'], + ['template', 'Template'], + ['time', 'Time'], + ['title', 'Title'], + ['tr', 'TableRow'], + ['track', 'Track'], + ['tt', ''], + ['u', ''], + ['ul', 'UList'], + ['var', ''], + ['video', 'Video'], + ['wbr', ''], + ['xmp', 'Pre'], +].forEach((e) => { + let tagName = e[0]; + let interfaceName = 'HTML' + e[1] + 'Element'; + promises.push(test_with_new_window((testWindow) => { + // Use window from iframe to isolate the test. + // Test calling the HTML*Element constructor. + (() => { + SimpleTest.doesThrow(() => { + testWindow[interfaceName](); + }, 'calling the ' + interfaceName + ' constructor should throw a TypeError'); + })(); + + // Test constructing a HTML*ELement. + (() => { + SimpleTest.doesThrow(() => { + new testWindow[interfaceName](); + }, 'constructing a ' + interfaceName + ' should throw a TypeError'); + })(); + + // Test constructing a custom element with defining HTML*Element as entry. + (() => { + testWindow.customElements.define('x-defining-' + tagName, + testWindow[interfaceName]); + SimpleTest.doesThrow(() => { + new testWindow[interfaceName](); + }, 'constructing a custom element with defining ' + interfaceName + + ' as registry entry should throw a TypeError'); + })(); + + // Since HTMLElement can be registered without specifying "extends", skip + // testing HTMLElement tags. + if (interfaceName !== "HTMLElement") { + // Test constructing a customized HTML*Element with defining a registry entry + // without specifying "extends". + (() => { + class X extends testWindow[interfaceName] {} + testWindow.customElements.define('x-defining-invalid-' + tagName, X); + SimpleTest.doesThrow(() => { + new X(); + }, 'constructing a customized ' + interfaceName + ' with defining a ' + + 'registry entry without specifying "extends" should throw a TypeError'); + })(); + } + + // Test constructing a built-in custom element with defining a registry entry + // with incorrect "extends" information. + (() => { + class X extends testWindow[interfaceName] {} + testWindow.customElements.define('x-defining-incorrect-' + tagName, X, + { extends: tagName === 'img' ? 'p' : 'img' }); + SimpleTest.doesThrow(() => { + new X(); + }, 'constructing a customized ' + interfaceName + ' with defining a ' + + 'registry entry with incorrect "extends" should throw a TypeError'); + })(); + + // Test calling a custom element constructor and constructing a built-in + // custom element. + (() => { + let num_constructor_invocations = 0; + class X extends testWindow[interfaceName] { + constructor() { + super(); + num_constructor_invocations++; + } + } + testWindow.customElements.define('x-' + tagName, X, { extends: tagName }); + SimpleTest.doesThrow(() => { + X(); + }, 'calling a customized ' + interfaceName + ' constructor should throw a TypeError'); + + let element = new X(); + + SimpleTest.is(Object.getPrototypeOf(Cu.waiveXrays(element)), X.prototype, + 'constructing a customized ' + interfaceName + + '; the element should be a registered constructor'); + SimpleTest.is(element.localName, tagName, + 'constructing a customized ' + interfaceName + + '; the element tag name should be "' + tagName + '"'); + SimpleTest.is(element.namespaceURI, 'http://www.w3.org/1999/xhtml', + 'constructing a customized ' + interfaceName + + '; the element should be in the HTML namespace'); + SimpleTest.is(element.prefix, null, + 'constructing a customized ' + interfaceName + + '; the element name should not have a prefix'); + SimpleTest.is(element.ownerDocument, testWindow.document, + 'constructing a customized ' + interfaceName + + '; the element should be owned by the registry\'s associated ' + + 'document'); + SimpleTest.is(num_constructor_invocations, 1, + 'constructing a customized ' + interfaceName + + '; the constructor should have been invoked once'); + })(); + + // Test if prototype is no an object. + (() => { + function ElementWithNonObjectPrototype() { + let o = Reflect.construct(testWindow[interfaceName], [], new.target); + SimpleTest.is(Object.getPrototypeOf(Cu.waiveXrays(o)), window[interfaceName].prototype, + 'constructing a customized ' + interfaceName + + '; if prototype is not object, fallback from NewTarget\'s realm'); + } + + // Prototype have to be an object during define(), otherwise define will + // throw an TypeError exception. + ElementWithNonObjectPrototype.prototype = {}; + testWindow.customElements.define('x-non-object-prototype-' + tagName, + ElementWithNonObjectPrototype, + { extends: tagName }); + + ElementWithNonObjectPrototype.prototype = "string"; + new ElementWithNonObjectPrototype(); + })(); + })); +}); diff --git a/dom/tests/mochitest/webcomponents/mochitest.ini b/dom/tests/mochitest/webcomponents/mochitest.ini index 496f7ea4d..3ab56de95 100644 --- a/dom/tests/mochitest/webcomponents/mochitest.ini +++ b/dom/tests/mochitest/webcomponents/mochitest.ini @@ -1,6 +1,7 @@ [DEFAULT] support-files = inert_style.css + dummy_page.html [test_bug900724.html] [test_bug1017896.html] @@ -11,6 +12,11 @@ support-files = [test_custom_element_callback_innerhtml.html] [test_custom_element_clone_callbacks.html] [test_custom_element_clone_callbacks_extended.html] +[test_custom_element_htmlconstructor.html] +skip-if = os == 'android' # bug 1323645 +support-files = + htmlconstructor_autonomous_tests.js + htmlconstructor_builtin_tests.js [test_custom_element_import_node_created_callback.html] [test_custom_element_in_shadow.html] [test_custom_element_register_invalid_callbacks.html] diff --git a/dom/tests/mochitest/webcomponents/test_custom_element_htmlconstructor.html b/dom/tests/mochitest/webcomponents/test_custom_element_htmlconstructor.html new file mode 100644 index 000000000..b022a7887 --- /dev/null +++ b/dom/tests/mochitest/webcomponents/test_custom_element_htmlconstructor.html @@ -0,0 +1,42 @@ + + + + + Test HTMLConstructor for custom elements. + + + + +Bug 1274159 + + + + + + + + diff --git a/dom/tests/mochitest/webcomponents/test_custom_element_htmlconstructor_chrome.html b/dom/tests/mochitest/webcomponents/test_custom_element_htmlconstructor_chrome.html new file mode 100644 index 000000000..8c7ec0ac6 --- /dev/null +++ b/dom/tests/mochitest/webcomponents/test_custom_element_htmlconstructor_chrome.html @@ -0,0 +1,41 @@ + + + + + Test HTMLConstructor for custom elements. + + + + +Bug 1274159 + + + + + + + + diff --git a/dom/tests/moz.build b/dom/tests/moz.build index f7c3e2437..7fc81abbd 100644 --- a/dom/tests/moz.build +++ b/dom/tests/moz.build @@ -37,6 +37,7 @@ MOCHITEST_CHROME_MANIFESTS += [ 'mochitest/geolocation/chrome.ini', 'mochitest/localstorage/chrome.ini', 'mochitest/sessionstorage/chrome.ini', + 'mochitest/webcomponents/chrome.ini', 'mochitest/whatwg/chrome.ini', ] -- cgit v1.2.3 From 3a97503b361b0b5ff1b5d8948a74497710f2a095 Mon Sep 17 00:00:00 2001 From: Gaming4JC Date: Thu, 2 Jan 2020 22:04:11 -0500 Subject: Bug 1309184 - Implement upgrade reaction for custom element reactions. Tag UXP Issue #1344 --- dom/base/CustomElementRegistry.cpp | 186 +++++++++++++++++++++++++++++++------ dom/base/CustomElementRegistry.h | 110 ++++++++++++++++++++++ 2 files changed, 267 insertions(+), 29 deletions(-) diff --git a/dom/base/CustomElementRegistry.cpp b/dom/base/CustomElementRegistry.cpp index 6cd213210..20eb59e94 100644 --- a/dom/base/CustomElementRegistry.cpp +++ b/dom/base/CustomElementRegistry.cpp @@ -137,6 +137,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(CustomElementRegistry) cb.NoteXPCOMChild(callbacks->mDetachedCallback.Value()); } } + NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mWhenDefinedPromiseMap) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mWindow) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END @@ -237,6 +238,7 @@ CustomElementRegistry::sProcessingStack; CustomElementRegistry::CustomElementRegistry(nsPIDOMWindowInner* aWindow) : mWindow(aWindow) , mIsCustomDefinitionRunning(false) + , mIsBackupQueueProcessing(false) { mozilla::HoldJSObjects(this); @@ -502,35 +504,7 @@ CustomElementRegistry::UpgradeCandidates(JSContext* aCx, continue; } - elem->RemoveStates(NS_EVENT_STATE_UNRESOLVED); - - // Make sure that the element name matches the name in the definition. - // (e.g. a definition for x-button extending button should match - //