From a448ed3c0c546cd0720f3cb1a6bb67014e45e45a Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Sat, 18 Jan 2020 13:01:53 +0100 Subject: [PATCH 01/18] 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 0000000000..7a2c76e943 --- /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. + + + From c8f73fb28e632daa4572494060136408f9cd71c4 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Sat, 18 Jan 2020 13:17:09 +0100 Subject: [PATCH 02/18] 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 22d8142c92..a9d926a535 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 From e2647e4529d9f3e7b1d240002ec9ddc73363d841 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Sat, 18 Jan 2020 13:25:35 +0100 Subject: [PATCH 03/18] 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 7a2c76e943..22a06e620a 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? From 7d2350c85927e7372fa5d18832d3f8fe81344fe1 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Sun, 19 Jan 2020 14:35:28 +0100 Subject: [PATCH 04/18] 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 a9a307da71..0256207669 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())) From 00d1bac44d4d550fff16f71a3087a4b4f5427112 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Sun, 19 Jan 2020 14:38:36 +0100 Subject: [PATCH 05/18] Issue #1362 - Revert "Implement regular expression lookbehind" This reverts commit fa473930f424bf17a9e545b601c84dd2e61364e3. --- .../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 | 149 +++++++----------- 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, 156 insertions(+), 358 deletions(-) diff --git a/js/src/irregexp/NativeRegExpMacroAssembler.cpp b/js/src/irregexp/NativeRegExpMacroAssembler.cpp index e17eecb9bb..0fb5072973 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 fc582dccf2..7a72e252ff 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 43867c3123..8dfd99057b 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 6f59842bcb..7bda6fc7e6 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 ea3f80b4f0..f31b78c593 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 62f94c3e72..4d691a5dc9 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); + bodyNode); } - compiler->set_read_backward(was_reading_backward); - return result; + + // 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 c4409dcca0..1a8fd4b220 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 d09b4671e4..7fd2d983a5 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 6b1ceba8ad..d66d0d204a 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 c5def92f29..dca2edf905 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 1ad044e8e2..d4308d0d84 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 ee57f04365..a58800a910 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_; From ffabfb276bcb06ab602c897f75e1b3cd5338e04c Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Sat, 18 Jan 2020 13:28:25 -0500 Subject: [PATCH 06/18] [Basilisk] Issue MoonchildProductions/UXP#1359 - Pointlessly rename greprefs.. again. --- application/basilisk/installer/package-manifest.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/basilisk/installer/package-manifest.in b/application/basilisk/installer/package-manifest.in index d98dff27a3..966ae58390 100644 --- a/application/basilisk/installer/package-manifest.in +++ b/application/basilisk/installer/package-manifest.in @@ -631,7 +631,7 @@ ; All the pref files must be part of base to prevent migration bugs @RESPATH@/browser/@PREF_DIR@/basilisk.js @RESPATH@/browser/@PREF_DIR@/basilisk-branding.js -@RESPATH@/greprefs.js +@RESPATH@/goanna.js @RESPATH@/defaults/autoconfig/prefcalls.js @RESPATH@/browser/defaults/permissions From 145a3c62e0b75a5f7c718089cd27d474d07a0269 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Sat, 18 Jan 2020 13:24:23 -0500 Subject: [PATCH 07/18] [Pale-Moon] Issue MoonchildProductions/UXP#1359 - Pointlessly rename greprefs.. again. --- application/palemoon/installer/package-manifest.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/palemoon/installer/package-manifest.in b/application/palemoon/installer/package-manifest.in index e24b605e80..521427918f 100644 --- a/application/palemoon/installer/package-manifest.in +++ b/application/palemoon/installer/package-manifest.in @@ -229,7 +229,7 @@ @RESPATH@/browser/defaults/permissions @RESPATH@/browser/@PREF_DIR@/palemoon.js @RESPATH@/browser/@PREF_DIR@/palemoon-branding.js -@RESPATH@/greprefs.js +@RESPATH@/goanna.js @RESPATH@/defaults/autoconfig/prefcalls.js ; Warning: changing the path to channel-prefs.js can cause bugs (Bug 756325) From 6f165b3446528d22f29f3d7f4ecc106f01cab1ae Mon Sep 17 00:00:00 2001 From: JustOff Date: Sun, 19 Jan 2020 17:47:56 +0200 Subject: [PATCH 08/18] [Pale-Moon] Issue #1708- Update UA override for GitHub --- application/palemoon/branding/shared/pref/uaoverrides.inc | 1 + 1 file changed, 1 insertion(+) diff --git a/application/palemoon/branding/shared/pref/uaoverrides.inc b/application/palemoon/branding/shared/pref/uaoverrides.inc index 4421e7fab2..4767d9151f 100644 --- a/application/palemoon/branding/shared/pref/uaoverrides.inc +++ b/application/palemoon/branding/shared/pref/uaoverrides.inc @@ -67,6 +67,7 @@ pref("@GUAO_PREF@.altibox.no","Mozilla/5.0 (@OS_SLICE@ rv:@GRE_VERSION@) @GRE_DA pref("@GUAO_PREF@.firefox.com","Mozilla/5.0 (@OS_SLICE@ rv:@GRE_VERSION@) @GRE_DATE_SLICE@ @PM_SLICE@"); pref("@GUAO_PREF@.mozilla.org","Mozilla/5.0 (@OS_SLICE@ rv:@GRE_VERSION@) @GRE_DATE_SLICE@ @PM_SLICE@"); pref("@GUAO_PREF@.mozilla.com","Mozilla/5.0 (@OS_SLICE@ rv:@GRE_VERSION@) @GRE_DATE_SLICE@ @PM_SLICE@"); +pref("@GUAO_PREF@.github.com","Mozilla/5.0 (@OS_SLICE@ rv:@GRE_VERSION@) @GRE_DATE_SLICE@ @PM_SLICE@"); // UA-Sniffing domains below have indicated no interest in supporting Pale Moon (BOO!) pref("@GUAO_PREF@.humblebundle.com","Mozilla/5.0 (@OS_SLICE@ rv:@GK_VERSION@) @GK_SLICE@ @FX_SLICE@ (Pale Moon)"); From 2aca38b3727ac9b6b54ae08072ff5298c71007a8 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Sat, 18 Jan 2020 13:17:41 -0500 Subject: [PATCH 09/18] Issue #1359 - Pointlessly rename greprefs.. again. --- modules/libpref/Preferences.cpp | 12 ++++++------ modules/libpref/{greprefs.js => goanna.js} | 0 modules/libpref/moz.build | 4 +--- python/mozbuild/mozpack/packager/formats.py | 2 +- .../mozbuild/mozpack/test/test_packager_formats.py | 4 ++-- .../mozapps/update/tests/data/xpcshellUtilsAUS.js | 2 +- 6 files changed, 11 insertions(+), 13 deletions(-) rename modules/libpref/{greprefs.js => goanna.js} (100%) diff --git a/modules/libpref/Preferences.cpp b/modules/libpref/Preferences.cpp index 19487704f5..840406635a 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/greprefs.js b/modules/libpref/goanna.js similarity index 100% rename from modules/libpref/greprefs.js rename to modules/libpref/goanna.js diff --git a/modules/libpref/moz.build b/modules/libpref/moz.build index 1c2c13e69a..1c9a51650b 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 c4adabab03..cedd1998bb 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 1af4336b25..66a7cc8e6e 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 ada08f0aeb..9a9610ddac 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); } From 45cb58760be8b0d54d41c55ea9dd4cb055b10727 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Sat, 18 Jan 2020 14:09:43 -0500 Subject: [PATCH 10/18] 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 fcc063fedb..5ea0c77ae4 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 705a0a08ad..7ebe2eaa7f 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 From abb2afe2a7629507839f75b0833df3decf7055ed Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Mon, 20 Jan 2020 11:59:36 +0100 Subject: [PATCH 11/18] 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 e56ce2f59f..b8d9da65c4 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 fce11cd6dc..7238d257f7 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 bbfec5000c..4a4dd7a53f 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 From 8d600c51edda02fc492c0e076c2af85d098ec7ae Mon Sep 17 00:00:00 2001 From: Gaming4JC Date: Tue, 21 Jan 2020 20:00:48 -0500 Subject: [PATCH 12/18] 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 -- .../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 - .../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 -- .../general/file_showModalDialog.html | 35 -- dom/tests/mochitest/general/mochitest.ini | 3 - .../general/test_showModalDialog.html | 60 ---- dom/webidl/Window.webidl | 14 - embedding/browser/nsIWebBrowserChrome.idl | 3 - .../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 ebaf07bcdf..6104ebfa71 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 ea4b052890..96a6c3ac01 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 47b46dda06..0587eb8927 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 1f420895c8..5cfd3f0563 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 47affbb062..5c07bf4d4d 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 d185275976..b8c9ac3579 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 b3b804ce4f..3dfd666f80 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 2cc8153099..0000000000 --- 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 70a091d000..0000000000 --- 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 bde07c79cb..a6de89595b 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 53bf49559e..828592d630 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 6d4347dfcf..0000000000 --- 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 9552307eed..0000000000 --- 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 07c5b66c18..0000000000 --- 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 024de1cd91..4a50a9c3f5 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 aa01a45de7..0000000000 --- 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 6d3a190eef..83f0e9045d 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 1307ea9a50..0000000000 --- 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 0472979d7b..6bd3aac947 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 bdbed6524b..8b4cea6d78 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 4bfc8337e8..0000000000 --- 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 dc11ced6ff..0000000000 --- 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 309aab6e02..3743c67822 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 1543cdd96a..0000000000 --- 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 2cd459ffa4..0000000000 --- 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 883e52bb49..0ee5cb393e 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 ecc2cb08d0..0000000000 --- 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 03db4ddea4..0000000000 --- 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 713165bc3d..0000000000 --- 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 4c6ce967da..ed16e099b1 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 e1a25a425e..0000000000 --- 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 1cae0b1c08..0000000000 --- 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 d00ea1d4bc..9f2fad7857 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 511c79e639..0000000000 --- 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 468f1cc8ad..ab03bf40b0 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 40f03cbe4f..32dba42195 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 e0e8b4bef6..3732ea66de 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 34d39354da..78e95458d6 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); From 9d76eb5791d8ccca643d62ea18d16c428bcef592 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Mon, 20 Jan 2020 22:35:36 +0100 Subject: [PATCH 13/18] Issue #1354 - Clear the current context when MakeCurrent() fails. --- dom/canvas/WebGLContextValidate.cpp | 7 +++++ gfx/gl/GLContext.cpp | 15 ++++----- 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, 82 insertions(+), 96 deletions(-) diff --git a/dom/canvas/WebGLContextValidate.cpp b/dom/canvas/WebGLContextValidate.cpp index ebf0aa8c2d..30d4c65221 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 1515b8627e..3fb87822d4 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()) { - mTexGarbageBin->GLContextTeardown(); - } else { - NS_WARNING("MakeCurrent() failed during MarkDestroyed! Skipping GL object teardown."); - } - + mIsDestroyed = true; mSymbols.Zero(); + if (MakeCurrent(true)) { + mTexGarbageBin->GLContextTeardown(); + } } #ifdef MOZ_GL_DEBUG diff --git a/gfx/gl/GLContext.h b/gfx/gl/GLContext.h index 6e3e22207f..4c1f4f55c9 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 1a29f3d155..23616d8610 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 1f2cee08da..0463669e99 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 ceab3046cb..7cc89eac9f 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 507616e2fa..11c7cce776 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 7979f3bf0b..23fc3472dc 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 (!mOwnsContext) { + return; } - if (mSurface == mSurfaceOverride) { - mSurfaceOverride = EGL_NO_SURFACE; - } - mSurface = EGL_NO_SURFACE; + + DestroySurface(mSurface); + mSurface = nullptr; } bool diff --git a/gfx/gl/GLContextProviderGLX.cpp b/gfx/gl/GLContextProviderGLX.cpp index 539520a8ce..178052f8cb 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 35957259de..da8c93d10a 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 From 305537e8d602d7f467a672829b51d560c1dbdb78 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Tue, 21 Jan 2020 21:23:46 +0100 Subject: [PATCH 14/18] 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 178052f8cb..c44b1a9f06 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! } From b33c6e6dbf3c2f5668ccd78ba94c00660523b1a7 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Wed, 22 Jan 2020 21:42:10 +0100 Subject: [PATCH 15/18] 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 0587eb8927..dd1fe45862 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 From 25ae10aaec6a83741df90aaccc0ad39e61fe0cbb Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Thu, 23 Jan 2020 13:08:02 +0100 Subject: [PATCH 16/18] 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 28d84973ec..bb832f6b75 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 10807cfb96..1512520e4c 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 b10324f0fb..29eef32105 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 dc5b4dca40..b386134f98 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 2b45ecb198..33482c6615 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 2b99e53b3d..20a5043fb1 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 b040ac870c..3c3ac8aa07 100644 --- a/old-configure.in +++ b/old-configure.in @@ -2014,44 +2014,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) @@ -5710,7 +5672,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 ebba07b4ad..85a7351ba3 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'] From a8daf97de0f391605c9d180e7f8ef143157d8f6c Mon Sep 17 00:00:00 2001 From: Kai Engert Date: Thu, 23 Jan 2020 13:11:09 +0100 Subject: [PATCH 17/18] 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 86b55fd9b2..55808f0f7d 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); From 0d69766fb3846ce616ae511ea5d0f569422ddb2d Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Thu, 23 Jan 2020 15:17:51 +0100 Subject: [PATCH 18/18] 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 216a1cf742..5ccfabd715 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