Closed
Bug 1142351
Opened 9 years ago
Closed 9 years ago
Add console warnings for non-standard flag argument of String.prototype.{search,match,replace}.
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
FIXED
mozilla39
Tracking | Status | |
---|---|---|
firefox39 | --- | fixed |
People
(Reporter: arai, Assigned: arai)
References
Details
(Keywords: dev-doc-complete, Whiteboard: [DocArea=JS])
Attachments
(2 files, 1 obsolete file)
3.25 KB,
patch
|
jandem
:
review+
|
Details | Diff | Splinter Review |
6.46 KB,
patch
|
jandem
:
review+
|
Details | Diff | Splinter Review |
Derived from bug 1108382. Now almost all in-tree consumers of flag argument of String.prototype.{search,match,replace} are fixed. Add deprecation warning for it, in the same way as other non-standard features. Adding also telemetry might be needed.
Updated•9 years ago
|
Keywords: dev-doc-needed
Updated•9 years ago
|
Whiteboard: [DocArea=JS]
Assignee | ||
Comment 1•9 years ago
|
||
To make sure it's safe to remove flags argument, added telemetry for it, as Part 1. Is there any other thing required to add telemetry item? Almost green on try runs: https://treeherder.mozilla.org/#/jobs?repo=try&revision=992de148a534 (forgot to add shell-only comment) https://treeherder.mozilla.org/#/jobs?repo=try&revision=c9f4dd0003d3 (fixed above)
Attachment #8579973 -
Flags: review?(jdemooij)
Assignee | ||
Comment 2•9 years ago
|
||
Attachment #8579974 -
Flags: review?(jdemooij)
Comment 3•9 years ago
|
||
Comment on attachment 8579973 [details] [diff] [review] Part 1: Collect telemetry about deprecated flag argument for String.prototype.{search,match,replace}. Review of attachment 8579973 [details] [diff] [review]: ----------------------------------------------------------------- Nice.
Attachment #8579973 -
Flags: review?(jdemooij) → review+
Comment 4•9 years ago
|
||
Comment on attachment 8579974 [details] [diff] [review] Part 2: Warn about deprecated flag argument for String.prototype.{search,match,replace}. Review of attachment 8579974 [details] [diff] [review]: ----------------------------------------------------------------- ::: js/src/jsstr.cpp @@ +2137,5 @@ > cx->compartment()->addTelemetry(filename, JSCompartment::DeprecatedFlagsArgument); > } > > + if (!JS_ReportErrorFlagsAndNumber(cx, JSREPORT_WARNING, GetErrorMessage, nullptr, > + JSMSG_DEPRECATED_FLAGS_ARG)) Reporting a warning each time the flags argument is used will slow us down a lot and will spam the browser's console. It'd be good to warn at most once per compartment/global. You can do something like I did in bug 1140428, or use GlobalObject::warnOnceAbout (vm/GlobalObject.h)
Attachment #8579974 -
Flags: review?(jdemooij)
Assignee | ||
Comment 5•9 years ago
|
||
Thank you for reviewing :D Added `warnedAboutFlagsArgument` member to compartment. Green on try run: https://treeherder.mozilla.org/#/jobs?repo=try&revision=7de970d52299
Attachment #8579974 -
Attachment is obsolete: true
Attachment #8581029 -
Flags: review?(jdemooij)
Comment 6•9 years ago
|
||
Comment on attachment 8581029 [details] [diff] [review] Part 2: Warn about deprecated flag argument for String.prototype.{search,match,replace}. Review of attachment 8581029 [details] [diff] [review]: ----------------------------------------------------------------- ::: js/src/js.msg @@ +231,5 @@ > MSG_DEF(JSMSG_CURLY_IN_COMPOUND, 0, JSEXN_SYNTAXERR, "missing } in compound statement") > MSG_DEF(JSMSG_DECLARATION_AFTER_EXPORT,0, JSEXN_SYNTAXERR, "missing declaration after 'export' keyword") > MSG_DEF(JSMSG_DECLARATION_AFTER_IMPORT,0, JSEXN_SYNTAXERR, "missing declaration after 'import' keyword") > MSG_DEF(JSMSG_DEPRECATED_DELETE_OPERAND, 0, JSEXN_SYNTAXERR, "applying the 'delete' operator to an unqualified name is deprecated") > +MSG_DEF(JSMSG_DEPRECATED_FLAGS_ARG, 0, JSEXN_NONE, "flags argument of String.prototype.{search,match,replace} are deprecated") Nit: s/are deprecated/is deprecated/ ::: js/src/tests/js1_5/String/replace-flags.js @@ +8,5 @@ > + > +options("werror"); > +assertEq(evaluate("'aaaA'.match('a', 'i')", {catchTermination: true}), "terminated"); > +assertEq(evaluate("'aaaA'.search('a', 'i')", {catchTermination: true}), "terminated"); > +assertEq(evaluate("'aaaA'.replace('a', 'b', 'g')", {catchTermination: true}), "terminated"); Does this test still pass, if we warn only once per compartment? If not you can probably do newGlobal().evaluate(...); it'll create a new compartment.
Attachment #8581029 -
Flags: review?(jdemooij) → review+
Assignee | ||
Comment 7•9 years ago
|
||
Thank you for reviewing :) (In reply to Jan de Mooij [:jandem] from comment #6) > ::: js/src/tests/js1_5/String/replace-flags.js > @@ +8,5 @@ > > + > > +options("werror"); > > +assertEq(evaluate("'aaaA'.match('a', 'i')", {catchTermination: true}), "terminated"); > > +assertEq(evaluate("'aaaA'.search('a', 'i')", {catchTermination: true}), "terminated"); > > +assertEq(evaluate("'aaaA'.replace('a', 'b', 'g')", {catchTermination: true}), "terminated"); > > Does this test still pass, if we warn only once per compartment? If not you > can probably do newGlobal().evaluate(...); it'll create a new compartment. Yes, because JS_ReportErrorFlagsAndNumber returns false after `options("werror")`, and `cx->compartment()->warnedAboutFlagsArgument = true;` is not evaluated in that case. is it better to do `cx->compartment()->warnedAboutFlagsArgument = true` before calling JS_ReportErrorFlagsAndNumber ?
Flags: needinfo?(jdemooij)
Comment 8•9 years ago
|
||
(In reply to Tooru Fujisawa [:arai] from comment #7) > Yes, because JS_ReportErrorFlagsAndNumber returns false after > `options("werror")`, and `cx->compartment()->warnedAboutFlagsArgument = > true;` is not evaluated in that case. Ah, right. > is it better to do `cx->compartment()->warnedAboutFlagsArgument = true` > before calling JS_ReportErrorFlagsAndNumber ? Since this only happens with the non-standard werror option, I don't think it matters too much. Either way is fine with me.
Flags: needinfo?(jdemooij)
Assignee | ||
Comment 9•9 years ago
|
||
Thanks again, I keep it as current. https://hg.mozilla.org/integration/mozilla-inbound/rev/a7556816cb5f https://hg.mozilla.org/integration/mozilla-inbound/rev/d802bf89d877
Assignee | ||
Updated•9 years ago
|
Assignee: nobody → arai.unmht
https://hg.mozilla.org/mozilla-central/rev/a7556816cb5f https://hg.mozilla.org/mozilla-central/rev/d802bf89d877
Status: NEW → RESOLVED
Closed: 9 years ago
status-firefox39:
--- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla39
Assignee | ||
Comment 11•9 years ago
|
||
Updated following documents: https://developer.mozilla.org/en-US/Firefox/Releases/39 https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/search match/search page says nothing about `flags`, so added only to "Firefox-specific notes".
Comment 12•9 years ago
|
||
Thanks arai! Let's not further advertise this, now that it will be gone at some point. The notes in the compat section are enough imo.
Keywords: dev-doc-needed → dev-doc-complete
You need to log in
before you can comment on or make changes to this bug.
Description
•