Skip to content

Fix: Spidermonkey dropped --utf8 flag #194

Merged
merged 1 commit into from May 1, 2013

2 participants

@Rob--W
Mozilla member
Rob--W commented Feb 14, 2013

Issue

Four months ago, Spidermonkey dropped the -U (--utf8) flag (see commit 53c97).

Consequently, amo-validator fails when the latest Spidermonkey binary is installed, because it returns the usage string (like js --help) and puts "Invalid short option: -U\n\n" in stderr.

Patch

This patch fixes the bug while remaining backwards-compatible. If backward-compatibility is not an issue, the solution can be simplified to removing , '-U' from line 170.

Steps to reproduce

  1. Get a recent Spidermonkey binary (eg. a nightly build of jsshell)
  2. Run addon-validator whatever-extension.xpi
  3. Result:
Traceback (most recent call last):
  File "/tmp/amo-validator/addon-validator", line 6, in <module>
    validator.main.main()
  File "/tmp/amo-validator/validator/main.py", line 133, in main
    timeout=timeout)
  File "/tmp/amo-validator/validator/validate.py", line 82, in validate
    timeout=timeout)
  File "/tmp/amo-validator/validator/submain.py", line 92, in prepare_package
    for_appversions)
  File "/tmp/amo-validator/validator/submain.py", line 160, in test_package
    output = test_inner_package(err, package, for_appversions)
  File "/tmp/amo-validator/validator/submain.py", line 338, in test_inner_package
    test_func(err, xpi_package)
  File "/tmp/amo-validator/validator/testcases/content.py", line 246, in test_packed_scripts
    pollutable=reversed_script in marked_scripts)
  File "/tmp/amo-validator/validator/testcases/scripting.py", line 43, in test_js_file
    tree = get_tree(data, filename=filename, shell=spidermonkey, err=err)
  File "/tmp/amo-validator/validator/testcases/javascript/spidermonkey.py", line 22, in get_tree
    return _get_tree(code, shell)
  File "/tmp/amo-validator/validator/testcases/javascript/spidermonkey.py", line 129, in _get_tree
    parsed = json.loads(data, strict=False)
  File "/usr/lib/python2.7/site-packages/simplejson/__init__.py", line 430, in loads
    return cls(encoding=encoding, **kw).decode(s)
  File "/usr/lib/python2.7/site-packages/simplejson/decoder.py", line 402, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python2.7/site-packages/simplejson/decoder.py", line 420, in raw_decode
    raise JSONDecodeError("No JSON object could be decoded", s, idx)
simplejson.decoder.JSONDecodeError: No JSON object could be decoded: line 1 column 0 (char 0)
@Rob--W Rob--W Fix: Spidermonkey dropped --utf8 flag
Four months ago, Spidermonkey dropped the `-U` (`--utf8`) flag (see mozilla/mozilla-central@53c97c#L16L4876). That change breaks (*) amo-validator when the latest version of Spidermonkey is installed. This proposal fixes the bug while maintaining backwards-compatible.

If you want to completely drop support for old Spidermonkey versions, removing `'-U'` from line 170 also fixes the bug.

(*) "breaks" = amo-validator crashes with a simplejson.decoder.JSONDecodeError, because `data` is not valid JSON. In fact, `data` holds the same value as `js --help` (Spidermonkey usage).
584d048
@mattbasta

This is going to take some clever planning so that there's no downtime. I'll talk to jason/oremj.

@Rob--W
Mozilla member
Rob--W commented Apr 11, 2013

Any updates?

@mattbasta

This is a difficult migration and we've been putting it off as long as possible. Ideally, we'll be moving away from Spidermonkey as our parser over the next year or so, so this might get wrapped up into that.

@mattbasta

I read through the patch a second time and realized that it's not backward-incompatible. Much appreciated!

@mattbasta mattbasta merged commit 318b2fb into mozilla:master May 1, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.