def test_fx13_interfaces(): """ Test that the Gecko 13 compatibility warnings and errors for matched patterns are thrown when they're supposed to. """ err = _do_real_test_raw(""" var x = Components.interfaces.nsILivemarkService; """, versions={FIREFOX_GUID: version_range("firefox", "13.0a1")}) assert not err.failed(fail_on_warnings=False) assert err.compat_summary["errors"] err = _do_real_test_raw(""" var x = Components.interfaces.nsIPrefBranch2; """, versions={FIREFOX_GUID: version_range("firefox", "13.0a1")}) assert not err.failed(fail_on_warnings=False) assert err.compat_summary["warnings"] err = _do_real_test_raw(""" var x = Components.interfaces.nsIScriptableUnescapeHTML; """, versions={FIREFOX_GUID: version_range("firefox", "13.0a1")}) assert not err.failed(fail_on_warnings=False) assert err.compat_summary["warnings"] err = _do_real_test_raw(""" var x = Components.interfaces.nsIAccessNode; """, versions={FIREFOX_GUID: version_range("firefox", "13.0a1")}) assert not err.failed(fail_on_warnings=False) assert err.compat_summary["errors"]
def document_getSelection(wrapper, arguments, traverser): """Flag Firefox 8 calls to document.getSelection().""" MDN_ARTICLE = "https://developer.mozilla.org/En/Window.getSelection" traverser.err.notice( err_id=("testcases_javascript_calldefinitions", "document_getSel"), notice="document.getSelection()'s return type has changed.", description="The return type of document.getSelection() has changed " "in Firefox 8. This function is deprecated, and you " "should be using window.getSelection() instead. See " "%s for more information." % MDN_ARTICLE, filename=traverser.filename, line=traverser.line, column=traverser.position, context=traverser.context, compatibility_type="error", for_appversions={'{ec8030f7-c20a-464f-9b0e-13a3a9e97384}': version_range("firefox", "8.0a1", "9.0a1"), '{3550f703-e582-4d05-9a08-453d09bdfdc6}': version_range("thunderbird", "8.0a1", "9.0a1"),}, tier=5) # The new spec returns an object. return JSWrapper(JSObject(), traverser=traverser)
def test_fx7_nsIDOMFile(): """Test that nsIDOMFile methods are flagged.""" err = _do_real_test_raw(""" var x = Components.classes.createInstance( Components.interfaces.nsIDOMFile); x.getAsBinary(); """) assert not err.failed(fail_on_warnings=False) assert not err.notices assert not any(err.compat_summary.values()) err = _do_real_test_raw(""" var x = Components.classes["foo"].createInstance( Components.interfaces.nsIDOMFile); x.getAsDataURL(); """, versions={FIREFOX_GUID: version_range("firefox", "7.0a1")}) assert not err.failed(fail_on_warnings=False) assert len(err.notices) == 1 assert err.compat_summary["errors"] err = _do_real_test_raw(""" var x = document.getElementById("whatever"); x.getAsDataURL(); """, versions={FIREFOX_GUID: version_range("firefox", "7.0a1")}) assert not err.failed() assert len(err.notices) == 1 assert err.compat_summary["errors"]
def amp_rp_bug660359(wrapper, arguments, traverser): """ Flag all calls to AddonManagerPrivate.registerProvider for incompatibility with Firefox 6. """ traverser.err.notice( err_id=("testcases_javascript_calldefinitions", "amp_rp_bug660359"), notice="Custom add-on types may not work properly in Firefox 6", description="This add-on appears to register custom add-on types, " "which are affected and may not work properly due to " "changes made on Firefox 6. For more information, " "please refer to " "https://bugzilla.mozilla.org/show_bug.cgi?id=595848", filename=traverser.filename, line=traverser.line, column=traverser.position, context=traverser.context, for_appversions={'{ec8030f7-c20a-464f-9b0e-13a3a9e97384}': version_range("firefox", "6.0a1", "7.0a1"), '{3550f703-e582-4d05-9a08-453d09bdfdc6}': version_range("thunderbird", "6.0a1", "7.0a1"),}, compatibility_type="error", tier=5)
def test_window_top(): """ Test that 'window.top' (a reserved global variable as of Firefox 6) is flagged as incompatible. """ err = _do_real_test_raw(""" window.top = "foo"; top = "bar"; """) print err.print_summary(verbose=True) assert not err.failed() assert not err.notices err = _do_real_test_raw(""" window.top = "foo"; """, versions={'{ec8030f7-c20a-464f-9b0e-13a3a9e97384}': version_range("firefox", "6.0a1")}) print err.print_summary(verbose=True) assert not err.failed() assert err.notices assert err.compat_summary["warnings"] err = _do_real_test_raw(""" top = "foo"; """, versions={'{ec8030f7-c20a-464f-9b0e-13a3a9e97384}': version_range("firefox", "6.0a1")}) print err.print_summary(verbose=True) assert not err.failed() assert err.notices assert err.compat_summary["warnings"]
def test_fx7_nsIDOMFile(): """Test that nsIDOMFile methods are flagged.""" err = _do_real_test_raw(""" var x = Components.classes.createInstance( Components.interfaces.nsIDOMFile); x.getAsBinary(); """) assert not err.failed() assert not err.notices assert not any(err.compat_summary.values()) err = _do_real_test_raw(""" var x = Components.classes["foo"].createInstance( Components.interfaces.nsIDOMFile); x.getAsDataURL(); """, versions={'{ec8030f7-c20a-464f-9b0e-13a3a9e97384}': version_range("firefox", "7.0a1")}) assert not err.failed() assert len(err.notices) == 1 assert err.compat_summary["errors"] err = _do_real_test_raw(""" var x = document.getElementById("whatever"); x.getAsDataURL(); """, versions={'{ec8030f7-c20a-464f-9b0e-13a3a9e97384}': version_range("firefox", "7.0a1")}) assert not err.failed() assert len(err.notices) == 1 assert err.compat_summary["errors"]
def test_tb7_deRDF_addressbook(): """Test that addressbook rdf sources are flagged""" err = _do_real_test_raw(""" var x = 'datasources="rdf:addressdirectory" ref="moz-abdirectory://"'; """) assert not err.failed() assert not err.notices err = _do_real_test_raw(""" var x = 'datasources="rdf:addressdirectory" ref="moz-abdirectory://"'; """, versions={TB_GUID: version_range("thunderbird", "7.0a1")}) assert not err.failed() assert err.notices assert err.compat_summary["errors"] err = _do_real_test_raw(""" var x = 'GetResource(SomeText).QueryInterface(6inTestxnsIAbDirectory);'; """) assert not err.failed() assert not err.notices err = _do_real_test_raw(""" var x = "GetResource(SomeText).QueryInterface(Some8678StuffnsIAbDirectory)"; """, versions={TB_GUID: version_range("thunderbird", "7.0a1")}) assert not err.failed() assert err.notices assert err.compat_summary["errors"]
def test_version_range_before(): """Test the `before` parameter of version_range.""" new_versions = {'1': {'guid': 'foo', 'versions': map(str, range(10))}} assert decorator.version_range('foo', '5', '6', app_versions=new_versions) == ['5'] assert decorator.version_range('foo', '8', '50', app_versions=new_versions) == ['8', '9']
def test_version_range_before(): """Test the `before` parameter of version_range.""" new_versions = {"1": {"guid": "foo", "versions": map(str, range(10))}} eq_(version_range("foo", "5", "6", app_versions=new_versions), ["5"]) eq_(version_range("foo", "8", "50", app_versions=new_versions), ["8", "9"])
def test_version_range_before(): """Test the `before` parameter of version_range.""" new_versions = {"1": {"guid": "foo", "versions": map(str, range(10))}} eq_(decorator.version_range("foo", "5", "6", app_versions=new_versions), ["5"]) eq_(decorator.version_range("foo", "8", "50", app_versions=new_versions), ["8", "9"])
def test_version_range(): """ Tests that the appropriate versions after the specified versions are returned. """ new_versions = {'1': {'guid': 'foo', 'versions': map(str, range(10))}} assert decorator.version_range('foo', '8', app_versions=new_versions) == ['8', '9'] assert decorator.version_range('foo', '5', app_versions=new_versions) == ['5', '6', '7', '8', '9']
def test_version_range(): """ Tests that the appropriate versions after the specified versions are returned. """ new_versions = {"1": {"guid": "foo", "versions": map(str, range(10))}} eq_(decorator.version_range("foo", "8", app_versions=new_versions), ["8", "9"]) eq_(decorator.version_range("foo", "5", app_versions=new_versions), ["5", "6", "7", "8", "9"])
def test_version_range(): """ Tests that the appropriate versions after the specified versions are returned. """ new_versions = {'1': {'guid': 'foo', 'versions': map(str, range(10))}} assert decorator.version_range('foo', '8', app_versions=new_versions) == ['8', '9'] assert decorator.version_range( 'foo', '5', app_versions=new_versions) == ['5', '6', '7', '8', '9']
def test_version_range(): """ Tests that the appropriate versions after the specified versions are returned. """ new_versions = {"1": {"guid": "foo", "versions": map(str, range(10))}} eq_(version_range("foo", "8", app_versions=new_versions), ["8", "9"]) eq_(version_range("foo", "5", app_versions=new_versions), ["5", "6", "7", "8", "9"])
def _readonly_top(traverser, right, node_right): """Handle the readonly callback for window.top.""" traverser.notice( err_id=('testcases_javascript_actions', '_readonly_top'), notice='window.top is a reserved variable', description='The `top` global variable is reserved and cannot be ' 'assigned any values starting with Gecko 6. Review your ' 'code for any uses of the `top` global, and refer to ' '%s for more information.' % BUGZILLA_BUG % 654137, for_appversions={ FIREFOX_GUID: version_range('firefox', '6.0a1', '7.0a1'), FENNEC_GUID: version_range('fennec', '6.0a1', '7.0a1') }, compatibility_type='warning', tier=5)
def test_requestAnimationFrame(): """ Test that requestAnimationFrame requires at least one parameter. """ err = _do_real_test_raw(""" requestAnimationFrame(foo); """, versions={FIREFOX_GUID: version_range("firefox", "11.0a1")}) assert not err.failed() err = _do_real_test_raw(""" requestAnimationFrame(); """, versions={FIREFOX_GUID: version_range("firefox", "11.0a1")}) assert err.failed() assert err.compat_summary["errors"]
def test_tb12_compatibility(): """ Test that the changed/removed interfaces for Thunderbird 12 are flagged. """ err = _do_real_test_raw(""" var x = Components.classes["foo"].createInstance( Components.interfaces.nsIMsgDBService); x.openMailDBFromFile(); var y = Components.classes["foo"].createInstance( Components.interfaces.nsIMsgDatabase); y.Open(); """) assert not err.failed(fail_on_warnings=False) assert not err.warnings assert not any(err.compat_summary.values()) err = _do_real_test_raw(""" var x = Components.classes["foo"].createInstance( Components.interfaces.nsIMsgDBService); x.openMailDBFromFile(); var y = Components.classes["foo"].createInstance( Components.interfaces.nsIMsgDatabase); y.Open(); """, versions={TB_GUID: version_range("thunderbird", "12.0a1")}) assert err.failed assert len(err.notices) == 2 assert err.compat_summary["errors"]
def test_tb11_compatibility(): """ Test that the changed/removed interfaces for Thunderbird 11 are flagged. """ err = _do_real_test_raw(""" var x = Components.classes["foo"].createInstance( Components.interfaces.nsIMsgQuote); x.quoteMessage(); var y = Components.classes["foo"].createInstance( Components.interfaces.nsIMailtoUrl); y.GetMessageContents(); """) assert not err.failed(fail_on_warnings=False) assert not err.warnings assert not any(err.compat_summary.values()) err = _do_real_test_raw(""" var x = Components.classes["foo"].createInstance( Components.interfaces.nsIMsgQuote); x.quoteMessage(); var y = Components.classes["foo"].createInstance( Components.interfaces.nsIMailtoUrl); y.GetMessageContents(); """, versions={TB_GUID: version_range("thunderbird", "11.0a1")}) assert err.failed assert len(err.notices) == 2 assert err.compat_summary["errors"]
def test_tb10_compatibility(): """ Test that MsgDeleteMessageFromMessageWindow, goToggleSplitter, AddMessageComposeOfflineObserver, and RemoveMessageComposeOfflineObserver are flagged. """ err = _do_real_test_raw(""" var x = ""; x = MsgDeleteMessageFromMessageWindow(); goToggleSplitter(); AddMessageComposeOfflineObserver(); RemoveMessageComposeOfflineObserver(); x = gDownloadManagerStrings.get(); """) assert not err.failed(fail_on_warnings=False) assert not err.warnings assert not any(err.compat_summary.values()) err = _do_real_test_raw(""" var x = ""; x = MsgDeleteMessageFromMessageWindow(); goToggleSplitter(); AddMessageComposeOfflineObserver(); RemoveMessageComposeOfflineObserver(); x = gDownloadManagerStrings.get(); """, versions={TB_GUID: version_range("thunderbird", "10.0a1")}) assert err.failed() assert len(err.warnings) == 1 assert len(err.notices) == 4 assert err.compat_summary["errors"]
def test_fx9_nsIBrowserHistory_removePages(): """ nsIBrowserHistory.removePages() takes 2 arguments instead of 3 in Firefox 9. """ futureCompatError( """ var browserHistory = Components.classes[ "@mozilla.org/browser/global-history;2"] .getService( Components.interfaces.nsIBrowserHistory); browserHistory.removePages(uriList, uriList.length, false); """, '9.0a1') err = _do_real_test_raw( """ var browserHistory = Components.classes[ "@mozilla.org/browser/global-history;2"] .getService( Components.interfaces.nsIBrowserHistory); browserHistory.removePages(uriList, uriList.length); """, versions={FIREFOX_GUID: version_range("firefox", "9.0a1")}) assert not err.failed(fail_on_warnings=False) assert not err.compat_summary["errors"]
def nsIMailtoUrl_changed(wrapper, arguments, traverser): """ Flag calls to nsIMailtoUrl.GetMessageContents for incompatibility with Thunderbird 11. """ traverser.err.notice( err_id=("testcases_javascript_calldefinitions", "nsIMsgQuote"), notice="Altered nsIMsgQuote.quoteMessage function in use.", description="This add-on appears to use nsIMailtoUrl." "GetMessageContents which was changed to" "nsIMailtoUrl.getMessageContents (lower case g) as part " "of Thunderbird 11. For more information, please refer to " "%s." % BUGZILLA_BUG % 711980, filename=traverser.filename, line=traverser.line, column=traverser.position, context=traverser.context, compatibility_type="error", for_appversions={ '{3550f703-e582-4d05-9a08-453d09bdfdc6}': version_range("thunderbird", "11.0a1", "12.0a1") }, tier=5) return JSWrapper(JSObject(), traverser=traverser, dirty=True)
def test_tb9_compatibility(): """ Test that gComposeBundle, FocusOnFirstAttachment, WhichPaneHasFocus are flagged. """ err = _do_real_test_raw(""" var x = ""; x = gComposeBundle(); FocusOnFirstAttachment(); WhichPaneHasFocus(); """) assert not err.failed(fail_on_warnings=False) assert not err.notices assert not any(err.compat_summary.values()) err = _do_real_test_raw(""" var x = ""; x = gComposeBundle(); FocusOnFirstAttachment(); WhichPaneHasFocus(); """, versions={TB_GUID: version_range("thunderbird", "9.0a1")}) assert not err.failed(fail_on_warnings=False) assert len(err.notices) == 3 assert err.compat_summary["errors"]
def _readonly_top(traverser, right, node_right): """Handle the readonly callback for window.top.""" traverser.notice( err_id=("testcases_javascript_actions", "_readonly_top"), notice="window.top is a reserved variable", description="The `top` global variable is reserved and cannot be " "assigned any values starting with Gecko 6. Review your " "code for any uses of the `top` global, and refer to " "%s for more information." % BUGZILLA_BUG % 654137, for_appversions={FIREFOX_GUID: version_range("firefox", "6.0a1", "7.0a1"), FENNEC_GUID: version_range("fennec", "6.0a1", "7.0a1")}, compatibility_type="warning", tier=5)
def test_tb7_mail_attachment_api(): """Test that the old mail attachment global functions are flagged.""" err = _do_real_test_raw(""" createNewAttachmentInfo(); saveAttachment(); attachmentIsEmpty(); openAttachment(); detachAttachment(); cloneAttachment(); """) assert not err.failed() assert not err.notices assert not any(err.compat_summary.values()) err = _do_real_test_raw(""" createNewAttachmentInfo(); saveAttachment(); attachmentIsEmpty(); openAttachment(); detachAttachment(); cloneAttachment(); """, versions={TB_GUID: version_range("thunderbird", "7.0a1")}) assert not err.failed() assert len(err.notices) == 6 assert err.compat_summary["errors"]
def TB9FocusFunctions_removed(wrapper, arguments, traverser): """ Flag calls to WhichPaneHasFocus and FocusOnFirstAttachment for incompatibility with Thunderbird 9 """ traverser.err.notice( err_id=("testcases_javascript_calldefinitions", "WhichPaneHasFocus"), notice= "Removed WhichPaneHasFocus or FocusOnFirstAttachment function in use.", description="This add-on appears to use WhichPaneHasFocus " "or FocusOnFirstAttachment which have been removed " "as part of changes made in Thunderbird 9. For more information, " "please refer to %s" % BUGZILLA_BUG % 581932, filename=traverser.filename, line=traverser.line, column=traverser.position, context=traverser.context, compatibility_type="error", for_appversions={ '{3550f703-e582-4d05-9a08-453d09bdfdc6}': version_range("thunderbird", "9.0a1", "10.0a1") }, tier=5) return JSWrapper(JSObject(), traverser=traverser, dirty=True)
def _readonly_top(traverser, right, node_right): """Handle the readonly callback for window.top.""" traverser.notice( err_id=('testcases_javascript_actions', '_readonly_top'), notice='window.top is a reserved variable', description='The `top` global variable is reserved and cannot be ' 'assigned any values starting with Gecko 6. Review your ' 'code for any uses of the `top` global, and refer to ' '%s for more information.' % BUGZILLA_BUG % 654137, for_appversions={FIREFOX_GUID: version_range('firefox', '6.0a1', '7.0a1'), FENNEC_GUID: version_range('fennec', '6.0a1', '7.0a1')}, compatibility_type='warning', tier=5)
def TB10Function_removed(wrapper, arguments, traverser): """ Flag calls to MsgDeleteMessageFromMessageWindow and goToggleSplitter for incompatibility with Thunderbird 10 """ traverser.err.notice( err_id=("testcases_javascript_calldefinitions", "MsgDeleteMessageFromMessageWindow"), notice= "Removed MsgDeleteMessageFromMessageWindow or goToggleSplitter function in use.", description= "This add-on appears to use MsgDeleteMessageFromMessageWindow " "or goToggleSplitter which have been removed " "as part of changes made in Thunderbird 10. For more information, " "please refer to %s and %s" % (BUGZILLA_BUG % 702201, BUGZILLA_BUG % 609245), filename=traverser.filename, line=traverser.line, column=traverser.position, context=traverser.context, compatibility_type="error", for_appversions={ '{3550f703-e582-4d05-9a08-453d09bdfdc6}': version_range("thunderbird", "10.0a1", "11.0a1") }, tier=5) return JSWrapper(JSObject(), traverser=traverser, dirty=True)
def TB10Function_renamed(wrapper, arguments, traverser): """ Flag calls to AddMessageComposeOfflineObserver and RemoveMessageComposeOfflineObserver for incompatibility with Thunderbird 10 """ traverser.err.notice( err_id=("testcases_javascript_calldefinitions", "AddMessageComposeOfflineObserver"), notice= "Removed AddMessageComposeOfflineObserver or goToggleSplitter function in use.", description= "This add-on appears to use AddMessageComposeOfflineObserver or " "RemoveMessageComposeOfflineObserver which have been renamed to " "AddMessageComposeOfflineQuitObserver and RemoveMessageComposeOfflineQuitObserver " "respectively as part of changes made in Thunderbird 10. For more information, " "please refer to %s" % BUGZILLA_BUG % 682581, filename=traverser.filename, line=traverser.line, column=traverser.position, context=traverser.context, compatibility_type="error", for_appversions={ '{3550f703-e582-4d05-9a08-453d09bdfdc6}': version_range("thunderbird", "10.0a1", "11.0a1") }, tier=5) return JSWrapper(JSObject(), traverser=traverser, dirty=True)
def test_fx9_nsIEditor_updateDefaultDictionary(): """ nsIEditorSpellCheck.UpdateDefaultDictionary takes no arguments in Firefox 9. """ futureCompatError( """ var spellChecker = Components.classes[ '@mozilla.org/editor/editorspellchecker;1'] .createInstance( Components.interfaces.nsIEditorSpellCheck); spellChecker.UpdateCurrentDictionary(null); """, '9.0a1') err = _do_real_test_raw( """ var spellChecker = Components.classes[ '@mozilla.org/editor/editorspellchecker;1'] .createInstance( Components.interfaces.nsIEditorSpellCheck); spellChecker.UpdateCurrentDictionary(); """, versions={FIREFOX_GUID: version_range("firefox", "9.0a1")}) assert not err.failed(fail_on_warnings=False) assert not err.compat_summary["errors"]
def test_fx9_nsIURLParser_parsePath(): """ nsIURLParser.parsePath takes 8 args instead of 10 now. """ futureCompatError( """ var URLi = Components.classes[ "@mozilla.org/network/url-parser;1?auth=maybe"]. createInstance(Components.interfaces.nsIURLParser); var filepathPos = {}, filepathLen = {}, paramPos = {}, paramLen = {}, queryPos = {}, queryLen = {}, refPos = {}, refLen = {}; URLi.parsePath(urlObj.path, -1, filepathPos, filepathLen, paramPos, paramLen, queryPos, queryLen, refPos, refLen); """, '9.0a1') err = _do_real_test_raw( """ var URLi = Components.classes[ "@mozilla.org/network/url-parser;1?auth=maybe"]. createInstance(Components.interfaces.nsIURLParser); var filepathPos = {}, filepathLen = {}, queryPos = {}, queryLen = {}, refPos = {}, refLen = {}; URLi.parsePath(urlObj.path, -1, filepathPos, filepathLen, queryPos, queryLen, refPos, refLen); """, versions={FIREFOX_GUID: version_range("firefox", "9.0a1")}) assert not err.failed(fail_on_warnings=False) assert not err.compat_summary["errors"]
def test_requestAnimationFrame(): """ Test that requestAnimationFrame requires at least one parameter. """ err = _do_real_test_raw(""" requestAnimationFrame(foo); """, versions={'{ec8030f7-c20a-464f-9b0e-13a3a9e97384}': version_range("firefox", "11.0a1")}) assert not err.failed() err = _do_real_test_raw(""" requestAnimationFrame(); """, versions={'{ec8030f7-c20a-464f-9b0e-13a3a9e97384}': version_range("firefox", "11.0a1")}) assert err.failed() assert err.compat_summary["errors"]
def test_fx8_compat(): """Test that FX8 compatibility tests are run.""" err = _do_real_test_raw(""" var x = "nsISelection2"; """) assert not err.failed() assert not err.notices err = _do_real_test_raw(""" var x = "nsISelection2"; """, versions={'{ec8030f7-c20a-464f-9b0e-13a3a9e97384}': version_range("firefox", "8.0a1")}) assert not err.failed() assert err.notices assert err.compat_summary["errors"] err = _do_real_test_raw(""" var x = "nsIDOMWindowInternal"; """) assert not err.failed() assert not err.notices err = _do_real_test_raw(""" var x = "nsIDOMWindowInternal"; """, versions={'{ec8030f7-c20a-464f-9b0e-13a3a9e97384}': version_range("firefox", "8.0a1")}) assert not err.failed() assert err.notices assert err.compat_summary["warnings"] err = _do_real_test_raw(""" var x = "ISO8601DateUtils"; """) assert not err.failed() assert not err.notices err = _do_real_test_raw(""" var x = "ISO8601DateUtils"; """, versions={'{ec8030f7-c20a-464f-9b0e-13a3a9e97384}': version_range("firefox", "8.0a1")}) assert not err.failed() assert err.notices assert err.compat_summary["errors"]
def test_startendMarker(): """ Test that _startMarker and _endMarker are properly flagged in Gecko 13. """ err = _do_real_test_raw(""" var foo = bar(); var x = foo._startMarker; var x = foo._endMarker; """) assert not err.failed() err = _do_real_test_raw(""" var foo = bar(); var x = foo._startMarker; """, versions={FIREFOX_GUID: version_range("firefox", "13.0a1")}) assert not err.failed() assert err.notices assert err.compat_summary["errors"] err = _do_real_test_raw(""" var foo = bar(); var x = foo._endMarker; """, versions={FIREFOX_GUID: version_range("firefox", "13.0a1")}) assert not err.failed() assert err.notices assert err.compat_summary["errors"] err = _do_real_test_raw(""" var foo = bar(); foo._startMarker = 1; """, versions={FIREFOX_GUID: version_range("firefox", "13.0a1")}) assert not err.failed() assert err.notices assert err.compat_summary["errors"] err = _do_real_test_raw(""" var foo = bar(); foo._endMarker = 1; """, versions={FIREFOX_GUID: version_range("firefox", "13.0a1")}) assert not err.failed() assert err.notices assert err.compat_summary["errors"]
def _readonly_top(t, r, rn): """Handle the readonly callback for window.top.""" t.err.notice( err_id=("testcases_javascript_actions", "_readonly_top"), notice="window.top is a reserved variable", description="The `top` global variable is reserved and cannot be " "assigned any values starting with Gecko 6. Review your " "code for any uses of the `top` global, and refer to " "%s for more information." % BUGZILLA_BUG % 654137, filename=t.filename, line=t.line, column=t.position, context=t.context, for_appversions={ FIREFOX_GUID: version_range("firefox", "6.0a1", "7.0a1"), FENNEC_GUID: version_range("fennec", "6.0a1", "7.0a1") }, compatibility_type="warning", tier=5)
def futureCompatError(code, version): err = _do_real_test_raw(code) assert not err.failed() assert not any(err.compat_summary.values()) err = _do_real_test_raw( code, versions={FIREFOX_GUID: version_range("firefox", version)}) print err.print_summary() assert err.failed() assert err.compat_summary["errors"]
def test_validate_libs_in_compat_mode(): xpi = 'tests/resources/libraryblacklist/addon_with_mootools.xpi' with open(xpi) as data: package = XPIManager(data, mode='r', name='addon_with_mootools.xpi') appversions = {FIREFOX_GUID: version_range('firefox', '39.0a1', '39.*')} err = ErrorBundle(for_appversions=appversions) test_content.test_packed_packages(err, package) assert err.get_resource('scripts'), ( 'expected mootools scripts to be marked for proessing') assert err.get_resource('scripts')[0]['scripts'] == set(['content/mootools.js'])
def futureCompatError(code, version): err = _do_real_test_raw(code) assert not err.failed(fail_on_warnings=False) assert not any(err.compat_summary.values()) err = _do_real_test_raw( code, versions={'{ec8030f7-c20a-464f-9b0e-13a3a9e97384}': version_range("firefox", version)}) assert err.failed(fail_on_warnings=False) assert err.compat_summary["errors"]
def test_fx12_interfaces(): """ Test that the Firefox 12 compatibility error interfaces throw compatibility errors when they're supposed to. """ err = _do_real_test_raw(""" var x = '<foo chromemargin="1">'; """, versions={'{ec8030f7-c20a-464f-9b0e-13a3a9e97384}': version_range("firefox", "12.0a1")}) assert not err.failed() assert not err.warnings assert err.notices assert err.compat_summary["errors"] err = _do_real_test_raw(""" var x = window.documentCharsetInfo; """, versions={'{ec8030f7-c20a-464f-9b0e-13a3a9e97384}': version_range("firefox", "12.0a1")}) assert not err.failed(fail_on_warnings=False) assert err.compat_summary["errors"] err = _do_real_test_raw(""" var x = Components.interfaces.nsIJetpack; """, versions={'{ec8030f7-c20a-464f-9b0e-13a3a9e97384}': version_range("firefox", "12.0a1")}) assert not err.failed(fail_on_warnings=False) assert err.compat_summary["errors"] err = _do_real_test_raw(""" var x = Components.interfaces.nsIJetpackService; """, versions={'{ec8030f7-c20a-464f-9b0e-13a3a9e97384}': version_range("firefox", "12.0a1")}) assert not err.failed(fail_on_warnings=False) assert err.compat_summary["errors"] err = _do_real_test_raw(""" var x = Components.interfaces.nsIProxyObjectManager; """, versions={'{ec8030f7-c20a-464f-9b0e-13a3a9e97384}': version_range("firefox", "12.0a1")}) assert not err.failed(fail_on_warnings=False) assert err.compat_summary["errors"]
def nsIDOMFile_deprec(wrapper, arguments, traverser): """Throw a compatibility error about removed XPCOM methods.""" traverser.err.notice( err_id=("testcases_javascript_calldefinitions", "nsIDOMFile", "deprec"), notice="Deprecated nsIDOMFile methods in use.", description=("Your add-on uses methods that have been removed from " "the nsIDOMFile interface in Firefox 7. Please refer to " "%s for more information.") % (BUGZILLA_BUG % 661876), filename=traverser.filename, line=traverser.line, column=traverser.position, context=traverser.context, compatibility_type="error", for_appversions={'{ec8030f7-c20a-464f-9b0e-13a3a9e97384}': version_range("firefox", "7.0a1", "8.0a1"), '{3550f703-e582-4d05-9a08-453d09bdfdc6}': version_range("thunderbird", "7.0a1", "8.0a1"),}, tier=5) return JSWrapper(JSObject(), traverser=traverser)
def test_validate_libs_in_compat_mode(): xpi = 'tests/resources/libraryblacklist/addon_with_mootools.xpi' with open(xpi) as data: package = XPIManager(data, mode='r', name='addon_with_mootools.xpi') appversions = { FIREFOX_GUID: version_range('firefox', '39.0a1', '39.*') } err = ErrorBundle(for_appversions=appversions) test_content.test_packed_packages(err, package) assert err.get_resource('scripts'), ( 'expected mootools scripts to be marked for proessing') assert err.get_resource('scripts')[0]['scripts'] == set( ['content/mootools.js'])
def _build_definition(maj_version_num, firefox=True, fennec=True, thunderbird=True, android=True): definition = {} app_version_range = ( lambda app: version_range(app, '%d.0a1' % maj_version_num, '%d.0a1' % (maj_version_num + 1))) if firefox: definition[FIREFOX_GUID] = app_version_range('firefox') if fennec: definition[FENNEC_GUID] = app_version_range('fennec') if thunderbird: definition[TB_GUID] = app_version_range('thunderbird') if android: definition[ANDROID_GUID] = app_version_range('android') return definition
def _build_definition(maj_version_num, firefox=True, fennec=True, thunderbird=True, android=True): definition = {} app_version_range = ( lambda app: version_range(app, "%d.0a1" % maj_version_num, "%d.0a1" % (maj_version_num + 1))) if firefox: definition[FIREFOX_GUID] = app_version_range("firefox") if fennec: definition[FENNEC_GUID] = app_version_range("fennec") if thunderbird: definition[TB_GUID] = app_version_range("thunderbird") if android: definition[ANDROID_GUID] = app_version_range("android") return definition
def test_app_update_timer(): """Flag instances of app.update.timer in compatibility.""" err = _do_test_raw(""" var f = app.update.timer; """) assert not err.failed() assert not any(err.compat_summary.values()) err = _do_test_raw(""" var f = app.update.timer; """, versions={"{ec8030f7-c20a-464f-9b0e-13a3a9e97384}": version_range("firefox", "6.0a1")}) assert not err.failed(fail_on_warnings=False) assert err.warnings assert err.compat_summary["errors"]
def gComposeBundle_removed(wrapper, arguments, traverser): """Flag uses of gComposeBundle for incompatibility with Thunderbird 9""" traverser.err.notice( err_id=("testcases_javascript_calldefinitions", "gComposeBundle"), notice="Removed gComposeBundle global variable in use.", description= "This add-on appears to use gComposeBundle which has been removed " "as part of changes made in Thunderbird 9. For more information, " "please refer to %s" % BUGZILLA_BUG % 670639, filename=traverser.filename, line=traverser.line, column=traverser.position, context=traverser.context, compatibility_type="error", for_appversions={ '{3550f703-e582-4d05-9a08-453d09bdfdc6}': version_range("thunderbird", "9.0a1", "10.0a1") }, tier=5) return JSWrapper(JSObject(), traverser=traverser, dirty=True)
def nsIMsgThread_removed(wrapper, arguments, traverser): """Flag calls to nsIMsgThread for incompatibility with Thunderbird 7""" traverser.err.notice( err_id=("testcases_javascript_calldefinitions", "nsIMsgThread"), notice="Removed nsIMsgThread method in use.", description="This add-on appears to use nsIMsgThread.GetChildAt, " "which may no longer work correctly due to " "changes made in Thunderbird 7. For more information, " "please refer to %s" % BUGZILLA_BUG % 617839, filename=traverser.filename, line=traverser.line, column=traverser.position, context=traverser.context, compatibility_type="error", for_appversions={ '{3550f703-e582-4d05-9a08-453d09bdfdc6}': version_range("thunderbird", "7.0a1", "8.0a1") }, tier=5) return JSWrapper(JSObject(), traverser=traverser, dirty=True)
def nsIComm4xProfile_removed(wrapper, arguments, traverser): """ Flag use of nsIComm4xProfile for incompatibility with Thunderbird 11 """ traverser.err.notice( err_id=("testcases_javascript_calldefinitions", "nsIComm4xProfile"), notice="Removed nsIComm4xProfile interface in use.", description="This add-on appears to use nsIComm4xProfile which was " "removed as part of changes made in Thunderbird 11. For " "more information, please refer to %s." % BUGZILLA_BUG % 689437, filename=traverser.filename, line=traverser.line, column=traverser.position, context=traverser.context, compatibility_type="error", for_appversions={ '{3550f703-e582-4d05-9a08-453d09bdfdc6}': version_range("thunderbird", "11.0a1", "12.0a1") }, tier=5) return JSWrapper(JSObject(), traverser=traverser, dirty=True)
def nsIImapMailFolderSink_changed(wrapper, arguments, traverser): """Flag calls to nsIImapMailFolderSink for possible incompatibility with Thunderbird 6""" traverser.err.notice( err_id=("testcases_javascript_calldefinitions", "nsIImapMailFolderSink"), notice="Modified nsIImapMailFolderSink method in use.", description= "This add-on appears to use nsIImapMailFolderSink.setUrlState, " "which may no longer work correctly due to " "changes made in Thunderbird 6. For more information, " "please refer to %s" % BUGZILLA_BUG % 464126, filename=traverser.filename, line=traverser.line, column=traverser.position, context=traverser.context, compatibility_type="error", for_appversions={ '{3550f703-e582-4d05-9a08-453d09bdfdc6}': version_range("thunderbird", "6.0a1", "8.0a1") }, tier=5) return JSWrapper(JSObject(), traverser=traverser, dirty=True)
def nsIMsgSearchScopeTerm_removed(wrapper, arguments, traverser): """Flag calls to nsIMsgSearchScopeTerm methods for incompatibility with Thunderbird 8""" traverser.err.notice( err_id=("testcases_javascript_calldefinitions", "nsIMsgSearchScopeTerm"), notice="Removed nsIMsgSearchScopeTerm method in use.", description= "This add-on appears to use nsIMsgSearchScopeTerm.mailFile or, " "nsIMsgSearchScopeTerm.inputStream, both of which have been removed" "as part of changes made in Thunderbird 8. For more information, " "please refer to %s" % BUGZILLA_BUG % 668700, filename=traverser.filename, line=traverser.line, column=traverser.position, context=traverser.context, compatibility_type="error", for_appversions={ '{3550f703-e582-4d05-9a08-453d09bdfdc6}': version_range("thunderbird", "8.0a1", "9.0a1") }, tier=5) return JSWrapper(JSObject(), traverser=traverser, dirty=True)
def mail_attachment_api(wrapper, arguments, traverser): """Flag calls to the global attachment functions for incompatibility with Thunderbird 7""" traverser.err.notice( err_id=("testcases_javascript_calldefinitions", "AttachmentAPI"), notice="Removed attachment API function in use.", description= "This add-on appears to use a global attachment function, one of: " "attachmentIsEmpty, cloneAttachment, createNewAttachmentInfo " "detachAttachment, openAttachment or saveAttachment, " "which were removed in Thunderbird 7. For more information, " "please refer to %s" % BUGZILLA_BUG % 657856, filename=traverser.filename, line=traverser.line, column=traverser.position, context=traverser.context, compatibility_type="error", for_appversions={ '{3550f703-e582-4d05-9a08-453d09bdfdc6}': version_range("thunderbird", "7.0a1", "8.0a1") }, tier=5) return JSWrapper(JSObject(), traverser=traverser, dirty=True)
def nsIMsgQuote_changed(wrapper, arguments, traverser): """ Flag calls to nsIMsgQuote.quoteMessage for incompatibility with Thunderbird 11 """ traverser.err.notice( err_id=("testcases_javascript_calldefinitions", "nsIMsgQuote"), notice="Altered nsIMsgQuote.quoteMessage function in use.", description= "This add-on appears to use nsIMsgQuote.quoteMessage which had the argument aOrigHdr" "added as part of changes made in Thunderbird 11. For more information, " "please refer to %s" % BUGZILLA_BUG % 351109, filename=traverser.filename, line=traverser.line, column=traverser.position, context=traverser.context, compatibility_type="error", for_appversions={ '{3550f703-e582-4d05-9a08-453d09bdfdc6}': version_range("thunderbird", "11.0a1", "12.0a1") }, tier=5) return JSWrapper(JSObject(), traverser=traverser, dirty=True)
def test_godlikea(err, xpi_package): """Test to make sure that the godlikea namespace is not in use.""" if "chrome/godlikea.jar" in xpi_package: err.error( err_id=("testcases_packagelayout", "test_godlikea"), error="Banned 'godlikea' chrome namespace", description="The 'godlikea' chrome namepsace is generated from a " "template and should be replaced with something " "unique to your add-on to avoid name conflicts.", filename="chrome/godlikea.jar") @decorator.register_test(tier=5, versions={ FIREFOX_GUID: version_range("firefox", FF4_MIN), TB_GUID: version_range("thunderbird", "3.3a4pre"), FENNEC_GUID: version_range("fennec", "4.0"), ANDROID_GUID: version_range("android", "11.0a1"), }) def test_compatibility_binary(err, xpi_package): """ Flags only binary content as being incompatible with future app releases. """ description = ("Add-ons with binary components must have their " "compatibility manually adjusted. Please test your add-on " "against the new version before updating your maxVersion.") chrome = err.get_resource("chrome.manifest") if not chrome:
def test_godlikea(err, xpi_package): """Test to make sure that the godlikea namespace is not in use.""" if 'chrome/godlikea.jar' in xpi_package: err.error( err_id=('testcases_packagelayout', 'test_godlikea'), error="Banned 'godlikea' chrome namespace", description="The 'godlikea' chrome namepsace is generated from a " 'template and should be replaced with something ' 'unique to your add-on to avoid name conflicts.', filename='chrome/godlikea.jar') @decorator.register_test(tier=5, versions={ FIREFOX_GUID: version_range('firefox', FF4_MIN), TB_GUID: version_range('thunderbird', '3.3a4pre'), FENNEC_GUID: version_range('fennec', '4.0'), ANDROID_GUID: version_range('android', '11.0a1') }) def test_compatibility_binary(err, xpi_package): """ Flags only binary content as being incompatible with future app releases. """ description = ('Add-ons with binary components must have their ' 'compatibility manually adjusted. Please test your add-on ' 'against the new version before updating your maxVersion.') chrome = err.get_resource('chrome.manifest') if not chrome:
from validator.decorator import version_range from validator.constants import (FIREFOX_GUID, FENNEC_GUID, THUNDERBIRD_GUID as TB_GUID, ANDROID_GUID) # Compatibility app/version ranges: FX4_DEFINITION = {FIREFOX_GUID: version_range("firefox", "3.7a1pre", "5.0a2"), FENNEC_GUID: version_range("fennec", "4.0b1pre", "5.0a2")} FX5_DEFINITION = {FIREFOX_GUID: version_range("firefox", "5.0a2", "6.0a1"), FENNEC_GUID: version_range("fennec", "5.0a2", "6.0a1")} def _build_definition(maj_version_num, firefox=True, fennec=True, thunderbird=True, android=True): definition = {} app_version_range = ( lambda app: version_range(app, "%d.0a1" % maj_version_num, "%d.0a1" % (maj_version_num + 1))) if firefox: definition[FIREFOX_GUID] = app_version_range("firefox") if fennec: definition[FENNEC_GUID] = app_version_range("fennec") if thunderbird: definition[TB_GUID] = app_version_range("thunderbird") if android: definition[ANDROID_GUID] = app_version_range("android") return definition FX6_DEFINITION = _build_definition(6, thunderbird=False, android=False) FX7_DEFINITION = _build_definition(7, android=False)