def test_comment_missing_everything(self): """If a frame is missing everything, do not throw an error.""" req = RequestFactory().get("/report/index") raw_crash = {} report = self._create_report() parsed_dump = self._create_dump( threads=[self._create_thread(frames=[{}])]) generate_create_bug_url(req, self.TEMPLATE, raw_crash, report, parsed_dump, 0)
def test_product_bug_links(self, fn): """Verify bug links templates are well-formed.""" product = productlib.load_product_from_file(fn) req = RequestFactory().get("/report/index") raw_crash = {"DOMFissionEnabled": "1"} report = self._create_report() for text, template in product.bug_links: # If there's an error in the template, it'll raise an exception here generate_create_bug_url(req, template, raw_crash, report, {}, 0)
def test_comment_no_threads(self): """If parsed_dump has no threads available, do not output any frames.""" req = RequestFactory().get("/report/index") raw_crash = {} report = self._create_report() url = generate_create_bug_url(req, self.TEMPLATE, raw_crash, report, {}, 0) assert quote_plus("frames of crashing thread:") not in url
def test_fission_enabled(self): """DOMFissionEnabled appends note to description.""" req = RequestFactory().get("/report/index") raw_crash = {"DOMFissionEnabled": "1"} report = self._create_report() url = generate_create_bug_url(req, self.TEMPLATE, raw_crash, report, {}, 0) assert "comment=Maybe+Fission+related.+%28DOMFissionEnabled%3D1%29" in url
def test_comment_more_than_ten_frames(self): """If the crashing thread has more than ten frames, only display top ten.""" req = RequestFactory().get("/report/index") raw_crash = {} report = self._create_report() parsed_dump = self._create_dump(threads=[ self._create_thread(frames=[ self._create_frame(frame=frame) for frame in range(10) ] + [self._create_frame(frame=10, module="do_not_include")]) ]) url = generate_create_bug_url(req, self.TEMPLATE, raw_crash, report, parsed_dump, 0) assert quote_plus("do_not_include") not in url
def test_truncate_short_desc(self): req = RequestFactory().get("/report/index") raw_crash = {} report = self._create_report(os_name="Windows", signature="x" * 1000) url = generate_create_bug_url( req, self.TEMPLATE, raw_crash, report, self.EMPTY_PARSED_DUMP, self.CRASHING_THREAD, ) qs = self._extract_query_string(url) assert len(qs["short_desc"][0]) == 255 assert qs["short_desc"][0].endswith("...")
def test_comment_java_stack_trace(self): """If there's a java stack trace, use that instead.""" req = RequestFactory().get("/report/index") raw_crash = {} report = self._create_report() report[ "java_stack_trace"] = "java.lang.NullPointerException: list == null" url = generate_create_bug_url(req, self.TEMPLATE, raw_crash, report, None, 0) assert quote_plus("Java stack trace:") in url assert quote_plus( "java.lang.NullPointerException: list == null") in url # Make sure it didn't also add the crashing frames assert quote_plus("frames of crashing thread:") not in url
def test_comment_reason(self): """Verify Reason makes it into the comment.""" req = RequestFactory().get("/report/index") raw_crash = {} report = self._create_report() report["reason"] = "SIGSEGV /0x00000080" parsed_dump = self._create_dump(threads=[ self._create_thread(frames=[ self._create_frame(frame=0), self._create_frame(frame=1), self._create_frame(frame=2), ]), ]) url = generate_create_bug_url(req, self.TEMPLATE, raw_crash, report, parsed_dump, 0) assert quote_plus("Reason: ```SIGSEGV /0x00000080```") in url
def test_comment_moz_crash_reason(self): """Verify Reason makes it into the comment.""" req = RequestFactory().get("/report/index") raw_crash = {} report = self._create_report() report["moz_crash_reason"] = "good_data" report["moz_crash_reason_raw"] = "bad_data" parsed_dump = self._create_dump(threads=[ self._create_thread(frames=[ self._create_frame(frame=0), self._create_frame(frame=1), self._create_frame(frame=2), ]), ]) url = generate_create_bug_url(req, self.TEMPLATE, raw_crash, report, parsed_dump, 0) assert quote_plus("MOZ_CRASH Reason: ```good_data```") in url assert quote_plus("bad_data") not in url
def test_comment_missing_file(self): """If a frame is missing file info, do not include it.""" req = RequestFactory().get("/report/index") raw_crash = {} report = self._create_report() parsed_dump = self._create_dump(threads=[ self._create_thread(frames=[ self._create_frame( frame=0, module="test_module", signature="foo::bar(char* x, int y)", file=None, line=None, ) ]) ]) url = generate_create_bug_url(req, self.TEMPLATE, raw_crash, report, parsed_dump, 0) assert quote_plus("0 test_module foo::bar \n") in url
def test_with_os_name_is_null(self): """Some processed crashes haev a os_name but it's null. FennecAndroid crashes for example. """ req = RequestFactory().get("/report/index") raw_crash = {} report = self._create_report( os_name=None, signature="java.lang.IllegalStateException") url = generate_create_bug_url( req, self.TEMPLATE, raw_crash, report, self.EMPTY_PARSED_DUMP, self.CRASHING_THREAD, ) qs = self._extract_query_string(url) assert "op_sys" not in qs
def test_comment_remove_arguments(self): """If a frame signature includes function arguments, remove them.""" req = RequestFactory().get("/report/index") raw_crash = {} report = self._create_report() parsed_dump = self._create_dump(threads=[ self._create_thread(frames=[ self._create_frame( frame=0, module="test_module", signature="foo::bar(char* x, int y)", file="foo.cpp", line=7, ) ]) ]) url = generate_create_bug_url(req, self.TEMPLATE, raw_crash, report, parsed_dump, 0) assert quote_plus("0 test_module foo::bar foo.cpp:7") in url
def test_basic_url(self): req = RequestFactory().get("/report/index") raw_crash = {} report = self._create_report(os_name="Windows") url = generate_create_bug_url( req, self.TEMPLATE, raw_crash, report, self.EMPTY_PARSED_DUMP, self.CRASHING_THREAD, ) qs = self._extract_query_string(url) assert "00000000-0000-0000-0000-000000000000" in qs["comment"][0] assert qs["cf_crash_signature"] == ["[@ $&#;deadbeef]"] assert qs["format"] == ["__default__"] assert qs["product"] == ["Firefox"] assert qs["rep_platform"] == ["x86"] assert qs["short_desc"] == ["Crash in [@ $&#;deadbeef]"] assert qs["op_sys"] == ["Windows"] assert qs["bug_type"] == ["defect"]
def test_comment_no_html_escaping(self): """If a frame contains <, >, &, or ", they should not be HTML escaped in the comment body. """ req = RequestFactory().get("/report/index") raw_crash = {} report = self._create_report() parsed_dump = self._create_dump(threads=[ self._create_thread(frames=[ self._create_frame( frame=0, module="&test_module", signature="foo<char>::bar(char* x, int y)", file='"foo".cpp', line=7, ) ]) ]) url = generate_create_bug_url(req, self.TEMPLATE, raw_crash, report, parsed_dump, 0) assert quote_plus('0 &test_module foo<char>::bar "foo".cpp:7') in url
def test_with_unicode_signature(self): """The jinja helper generate_create_bug_url should work when the signature contains non-ascii characters. Based on an actual error in production: https://bugzilla.mozilla.org/show_bug.cgi?id=1383269 """ req = RequestFactory().get("/report/index") raw_crash = {} report = self._create_report( os_name=None, signature="YouTube\u2122 No Buffer (Stop Auto-playing)") url = generate_create_bug_url( req, self.TEMPLATE, raw_crash, report, self.EMPTY_PARSED_DUMP, self.CRASHING_THREAD, ) # Most important that it should work assert ( "Crash+in+%5B%40+YouTube%E2%84%A2+No+Buffer+%28Stop+Auto-playing%29%5D" in url)
def test_comment(self): req = RequestFactory().get("/report/index") raw_crash = {} report = self._create_report() parsed_dump = self._create_dump(threads=[ self._create_thread(), # Empty thread 0 self._create_thread(frames=[ self._create_frame(frame=0), self._create_frame(frame=1), self._create_frame(frame=2), ]), ]) url = generate_create_bug_url(req, self.TEMPLATE, raw_crash, report, parsed_dump, 1) # Assert that the crash id is in the comment assert quote_plus(report["uuid"]) in url # Assert that the top 3 frames are in the comment assert quote_plus("Top 3 frames of crashing thread:") in url frame1 = parsed_dump["threads"][1]["frames"][1] assert (quote_plus( "1 {module} {signature} {file}:{line}".format(**frame1)) in url)
def test_corrected_os_version_name(self): req = RequestFactory().get("/report/index") raw_crash = {} report = self._create_report(os_name="Windoooosws", os_pretty_version="Windows 10") url = generate_create_bug_url( req, self.TEMPLATE, raw_crash, report, self.EMPTY_PARSED_DUMP, self.CRASHING_THREAD, ) qs = self._extract_query_string(url) assert qs["op_sys"] == ["Windows 10"] # os_name if the os_pretty_version is there, but empty report = self._create_report(os_name="Windoooosws", os_pretty_version="") url = generate_create_bug_url( req, self.TEMPLATE, raw_crash, report, self.EMPTY_PARSED_DUMP, self.CRASHING_THREAD, ) qs = self._extract_query_string(url) assert qs["op_sys"] == ["Windoooosws"] # "OS X <Number>" becomes "macOS" report = self._create_report(os_name="OS X", os_pretty_version="OS X 11.1") url = generate_create_bug_url( req, self.TEMPLATE, raw_crash, report, self.EMPTY_PARSED_DUMP, self.CRASHING_THREAD, ) qs = self._extract_query_string(url) assert qs["op_sys"] == ["macOS"] # "Windows 8.1" becomes "Windows 8" report = self._create_report(os_name="Windows NT", os_pretty_version="Windows 8.1") url = generate_create_bug_url( req, self.TEMPLATE, raw_crash, report, self.EMPTY_PARSED_DUMP, self.CRASHING_THREAD, ) qs = self._extract_query_string(url) assert qs["op_sys"] == ["Windows 8"] # "Windows Unknown" becomes plain "Windows" report = self._create_report(os_name="Windows NT", os_pretty_version="Windows Unknown") url = generate_create_bug_url( req, self.TEMPLATE, raw_crash, report, self.EMPTY_PARSED_DUMP, self.CRASHING_THREAD, ) qs = self._extract_query_string(url) assert qs["op_sys"] == ["Windows"]