Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge pull request #224 from mstriemer/livemarks-compatibility-994986

warn about the deprecation of livemark callbacks (bug 994986)
  • Loading branch information...
commit 1ad61b64d4fff244e06cd98d94f644dc70025000 2 parents cd1139a + 54722f2
Mark Striemer authored April 15, 2014
50  tests/compat/test_gecko29.py
... ...
@@ -0,0 +1,50 @@
  1
+from helper import CompatTestCase
  2
+from validator.compat import FX29_DEFINITION
  3
+
  4
+
  5
+class TestFX29Compat(CompatTestCase):
  6
+    """Test that compatibility tests for Firefox 29 are properly executed."""
  7
+
  8
+    VERSION = FX29_DEFINITION
  9
+
  10
+    def test_callback_warning_add(self):
  11
+        self.run_script_for_compat(
  12
+            'PlacesUtils.livemarks.addLivemark("foo", bar);')
  13
+        self.assert_silent()
  14
+        self.assert_compat_error()
  15
+
  16
+    def test_callback_warning_remove(self):
  17
+        self.run_script_for_compat(
  18
+            'PlacesUtils.livemarks.removeLivemark("foo", bar);')
  19
+        self.assert_silent()
  20
+        self.assert_compat_error()
  21
+
  22
+    def test_callback_warning_get(self):
  23
+        self.run_script_for_compat('''
  24
+            PlacesUtils.livemarks.getLivemark("foo", function () {
  25
+                alert("done!");
  26
+            });
  27
+        ''')
  28
+        self.assert_silent()
  29
+        self.assert_compat_error()
  30
+
  31
+    def test_no_callback_no_warning_add(self):
  32
+        self.run_script_for_compat(
  33
+            'var promise = PlacesUtils.livemarks.addLivemark("foo");')
  34
+        self.assert_silent()
  35
+        self.assert_compat_silent()
  36
+
  37
+    def test_no_callback_no_warning_remove(self):
  38
+        self.run_script_for_compat('''
  39
+            var promise = PlacesUtils.livemarks.removeLivemark({
  40
+                foo: "foo",
  41
+                bar: "bar",
  42
+            });''')
  43
+        self.assert_silent()
  44
+        self.assert_compat_silent()
  45
+
  46
+    def test_no_callback_no_warning_get(self):
  47
+        self.run_script_for_compat(
  48
+            'var promise = PlacesUtils.livemarks.getLivemark("foo");')
  49
+        self.assert_silent()
  50
+        self.assert_compat_silent()
1  validator/compat.py
@@ -50,6 +50,7 @@ def _build_definition(maj_version_num, firefox=True, fennec=True,
50 50
 FX26_DEFINITION = _build_definition(26)
51 51
 FX27_DEFINITION = _build_definition(27)
52 52
 FX28_DEFINITION = _build_definition(28)
  53
+FX29_DEFINITION = _build_definition(29)
53 54
 
54 55
 _tb_definition = (lambda ver:
55 56
     _build_definition(ver, firefox=False, fennec=False, android=False))
32  validator/testcases/javascript/instanceactions.py
@@ -13,8 +13,8 @@
13 13
 import types
14 14
 
15 15
 import actions
16  
-from validator.compat import FX10_DEFINITION, FX14_DEFINITION
17  
-from validator.constants import BUGZILLA_BUG
  16
+from validator.compat import FX10_DEFINITION, FX14_DEFINITION, FX29_DEFINITION
  17
+from validator.constants import BUGZILLA_BUG, MDN_DOC
18 18
 from jstypes import *
19 19
 from instanceproperties import _set_HTML_property
20 20
 
@@ -257,6 +257,31 @@ def bind(args, traverser, node, wrapper):
257 257
         return obj
258 258
 
259 259
 
  260
+def livemarkCallback(arguments, traverser, node, wrapper):
  261
+    """
  262
+    Handle calls to addLivemark, removeLivemark and getLivemark that pass
  263
+    callbacks.
  264
+    """
  265
+    bug = BUGZILLA_BUG % 896193
  266
+    mdn = MDN_DOC % "Mozilla/JavaScript_code_modules/Promise.jsm"
  267
+    if len(arguments) > 1:
  268
+        traverser.err.warning(
  269
+            err_id=("js", "instanceactions", "livemark_callback"),
  270
+            warning="Passing a callback to `addLivemark`, `removeLivemark` or "
  271
+                    "`getLivemark` is deprecated.",
  272
+            description="The asynchronous callbacks in these livemark "
  273
+                        "functions are now deprecated. The functions now "
  274
+                        "return promises that should be used instead. See {b} "
  275
+                        "and {m} for more information.".format(b=bug, m=mdn),
  276
+            compatibility_type='warning',
  277
+            for_appversions=FX29_DEFINITION,
  278
+            tier=3,
  279
+            filename=traverser.filename,
  280
+            line=traverser.line,
  281
+            column=traverser.position,
  282
+            context=traverser.context)
  283
+
  284
+
260 285
 INSTANCE_DEFINITIONS = {
261 286
     "addEventListener": addEventListener,
262 287
     "bind": bind,
@@ -272,4 +297,7 @@ def bind(args, traverser, node, wrapper):
272 297
     "QueryInterface": QueryInterface,
273 298
     "replaceWholeText": replaceWholeText,
274 299
     "setAttribute": setAttribute,
  300
+    "addLivemark": livemarkCallback,
  301
+    "removeLivemark": livemarkCallback,
  302
+    "getLivemark": livemarkCallback,
275 303
 }
37  validator/testcases/regex.py
@@ -2,20 +2,17 @@
2 2
 from functools import wraps
3 3
 
4 4
 from validator.constants import BUGZILLA_BUG, MDN_DOC
5  
-from validator.compat import (FX4_DEFINITION, FX5_DEFINITION, FX6_DEFINITION,
6  
-                              FX7_DEFINITION, FX8_DEFINITION, FX9_DEFINITION,
7  
-                              FX11_DEFINITION, FX12_DEFINITION, FX13_DEFINITION,
8  
-                              FX14_DEFINITION, FX15_DEFINITION, FX16_DEFINITION,
9  
-                              FX17_DEFINITION, FX18_DEFINITION, FX19_DEFINITION,
10  
-                              FX20_DEFINITION, FX21_DEFINITION, FX22_DEFINITION,
11  
-                              FX23_DEFINITION, FX24_DEFINITION, FX25_DEFINITION,
12  
-                              FX26_DEFINITION, FX27_DEFINITION, FX28_DEFINITION,
13  
-                              TB7_DEFINITION, TB10_DEFINITION, TB11_DEFINITION,
14  
-                              TB12_DEFINITION, TB13_DEFINITION, TB14_DEFINITION,
15  
-                              TB15_DEFINITION, TB16_DEFINITION, TB17_DEFINITION,
16  
-                              TB18_DEFINITION, TB19_DEFINITION, TB20_DEFINITION,
17  
-                              TB21_DEFINITION, TB22_DEFINITION, TB23_DEFINITION,
18  
-                              TB24_DEFINITION)
  5
+from validator.compat import (
  6
+    FX4_DEFINITION, FX5_DEFINITION, FX6_DEFINITION, FX7_DEFINITION,
  7
+    FX8_DEFINITION, FX9_DEFINITION, FX11_DEFINITION, FX12_DEFINITION,
  8
+    FX13_DEFINITION, FX14_DEFINITION, FX15_DEFINITION, FX16_DEFINITION,
  9
+    FX17_DEFINITION, FX18_DEFINITION, FX19_DEFINITION, FX20_DEFINITION,
  10
+    FX21_DEFINITION, FX22_DEFINITION, FX23_DEFINITION, FX24_DEFINITION,
  11
+    FX25_DEFINITION, FX26_DEFINITION, FX27_DEFINITION, FX28_DEFINITION,
  12
+    TB7_DEFINITION, TB10_DEFINITION, TB11_DEFINITION, TB12_DEFINITION,
  13
+    TB13_DEFINITION, TB14_DEFINITION, TB15_DEFINITION, TB16_DEFINITION,
  14
+    TB17_DEFINITION, TB18_DEFINITION, TB19_DEFINITION, TB20_DEFINITION,
  15
+    TB21_DEFINITION, TB22_DEFINITION, TB23_DEFINITION, TB24_DEFINITION)
19 16
 from validator.contextgenerator import ContextGenerator
20 17
 from markup.csstester import UNPREFIXED_MESSAGE
21 18
 
@@ -1294,12 +1291,12 @@ class Gecko28RegexTests(CompatRegexTestHelper):
1294 1291
 
1295 1292
     def js_tests(self):
1296 1293
         yield self.get_test_bug(
1297  
-                self.BUG_ID, r"__SS_tabStillLoading",
1298  
-                "The `__SS_tabStillLoading` property was removed.",
1299  
-                "The `__SS_tabStillLoading` property was removed. You can "
1300  
-                "check the existence of `__SS_data` instead. See %s for more "
1301  
-                "information." % BUGZILLA_BUG % self.BUG_ID,
1302  
-                compat_type="error", log_function=self.err.warning)
  1294
+            self.BUG_ID, r"__SS_tabStillLoading",
  1295
+            "The `__SS_tabStillLoading` property was removed.",
  1296
+            "The `__SS_tabStillLoading` property was removed. You can "
  1297
+            "check the existence of `__SS_data` instead. See %s for more "
  1298
+            "information." % BUGZILLA_BUG % self.BUG_ID,
  1299
+            compat_type="error", log_function=self.err.warning)
1303 1300
 
1304 1301
 
1305 1302
 #############################

0 notes on commit 1ad61b6

Please sign in to comment.
Something went wrong with that request. Please try again.