Skip to content

Commit

Permalink
Added importHTML* tests (bug 766751)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattbasta committed Jun 29, 2012
1 parent f309eb3 commit 16693bb
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 2 deletions.
32 changes: 32 additions & 0 deletions tests/test_compatibility.py
Expand Up @@ -1115,3 +1115,35 @@ def test_startendMarker():
assert err.notices
assert err.compat_summary["errors"]


def test_fx14_importhtml():
"""
Test that the importHTMLFromFile and importHTMLFromURI functions are both
flagged in FX14.
"""

err = _do_real_test_raw("""
var x = Components.classes["foo"].createInstance(
Components.interfaces.nsIPlacesImportExportService);
x.importHTMLFromFile();
x.importHTMLFromURI();
""")
assert not err.failed()
assert not err.compat_summary["errors"]

err = _do_real_test_raw("""
var x = Components.classes["foo"].createInstance(
Components.interfaces.nsIPlacesImportExportService);
x.importHTMLFromFile();
""", versions={FIREFOX_GUID: version_range("firefox", "14.0a1")})
assert err.failed()
assert err.compat_summary["errors"]

err = _do_real_test_raw("""
var x = Components.classes["foo"].createInstance(
Components.interfaces.nsIPlacesImportExportService);
x.importHTMLFromURI();
""", versions={FIREFOX_GUID: version_range("firefox", "14.0a1")})
assert err.failed()
assert err.compat_summary["errors"]

1 change: 1 addition & 0 deletions validator/compat.py
Expand Up @@ -38,6 +38,7 @@ def _build_definition(maj_version_num, firefox=True, fennec=True,
FX11_DEFINITION = _build_definition(11, android=True)
FX12_DEFINITION = _build_definition(12, android=True)
FX13_DEFINITION = _build_definition(13, android=True)
FX14_DEFINITION = _build_definition(14, android=True)

TB7_DEFINITION = {TB_GUID: version_range("thunderbird", "7.0a1", "8.0a1")}
TB10_DEFINITION = {TB_GUID: version_range("thunderbird", "10.0a1", "11.0a1")}
Expand Down
29 changes: 28 additions & 1 deletion validator/testcases/javascript/entity_values.py
@@ -1,4 +1,4 @@
from validator.compat import FX10_DEFINITION
from validator.compat import FX10_DEFINITION, FX14_DEFINITION
from validator.constants import BUGZILLA_BUG


Expand All @@ -25,6 +25,33 @@ def return_wrap(t):
return {"value": return_wrap}


def deprecated_entity(name, version, message, bug, status="deprecated",
compat_type="error"):
def wrap(traverser):
traverser.err.warning(
err_id=("testcases_javascript_entity_values", name),
warning="`%s` has been %s.",
description=[message,
"See %s for more information." % BUGZILLA_BUG % bug],
filename=traverser.filename,
line=traverser.line,
column=traverser.position,
context=traverser.context,
for_appversions=version,
compatibility_type=compat_type,
tier=5)
register_entity(name)(wrap)

DEP_IHF_MESSAGE = ("The `importHTMLFromFile` and `importHTMLFromURI` functions "
"have been removed from the `nsIPlacesImportExportService` "
"interface. You can use the equivalent functions in the "
"`BookmarkHTMLUtils` module instead.")
deprecated_entity(name="importHTMLFromFile", version=FX14_DEFINITION,
message=DEP_IHF_MESSAGE, bug=482911)
deprecated_entity(name="importHTMLFromURI", version=FX14_DEFINITION,
message=DEP_IHF_MESSAGE, bug=482911)


@register_entity("document.xmlEncoding")
def xmlEncoding(traverser):
traverser.err.error(
Expand Down
7 changes: 6 additions & 1 deletion validator/testcases/javascript/predefinedentities.py
Expand Up @@ -41,6 +41,7 @@
r"extensions\..*\.update\.(url|enabled|interval)",
]


# See https://github.com/mattbasta/amo-validator/wiki/JS-Predefined-Entities
# for details on entity properties.

Expand Down Expand Up @@ -249,7 +250,11 @@
call_definitions.spellcheck_updatecurrentdictionary},
u"saveDefaultDictionary":
{"value":
call_definitions.spellcheck_savedefaultdictionary}}}
call_definitions.spellcheck_savedefaultdictionary}}},
u"nsIPlacesImportExportService":
{"value":
{u"importHTMLFromFile": entity("importHTMLFromFile"),
u"importHTMLFromURI": entity("importHTMLFromURI"),}}
}

INTERFACE_ENTITIES = {u"nsIXMLHttpRequest":
Expand Down

0 comments on commit 16693bb

Please sign in to comment.