summaryrefslogtreecommitdiffstats
path: root/js/src/builtin
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@wolfbeast.com>2019-11-30 00:46:07 +0100
committerwolfbeast <mcwerewolf@wolfbeast.com>2019-11-30 00:46:07 +0100
commitd88f471cbcf9f6c8682b6a0c152622b66708ac5b (patch)
tree69fc7c4c11a26dff3f813fd13b5205fb3b765e11 /js/src/builtin
parent6ea8e51aaa192d920ffd6b8a7d4cc4e998d7222a (diff)
downloadUXP-d88f471cbcf9f6c8682b6a0c152622b66708ac5b.tar
UXP-d88f471cbcf9f6c8682b6a0c152622b66708ac5b.tar.gz
UXP-d88f471cbcf9f6c8682b6a0c152622b66708ac5b.tar.lz
UXP-d88f471cbcf9f6c8682b6a0c152622b66708ac5b.tar.xz
UXP-d88f471cbcf9f6c8682b6a0c152622b66708ac5b.zip
Issue #1302 followup - Add spec-compliance checks/errors
- Check for undefined/null regex flags (because...) - Make it throw a typeerror instead of syntax error on non-global - Generalize JS error messages for these checks.
Diffstat (limited to 'js/src/builtin')
-rw-r--r--js/src/builtin/RegExp.js7
1 files changed, 5 insertions, 2 deletions
diff --git a/js/src/builtin/RegExp.js b/js/src/builtin/RegExp.js
index 25827743e..91212066c 100644
--- a/js/src/builtin/RegExp.js
+++ b/js/src/builtin/RegExp.js
@@ -1042,6 +1042,9 @@ function RegExpMatchAll(string) {
// Step 2.
if (!IsObject(rx))
ThrowTypeError(JSMSG_NOT_NONNULL_OBJECT, rx === null ? "null" : typeof rx);
+
+ if (rx.flags === undefined || rx.flags === null)
+ ThrowTypeError(JSMSG_FLAGS_UNDEFINED_OR_NULL);
// Step 3.
var str = ToString(string);
@@ -1052,9 +1055,9 @@ function RegExpMatchAll(string) {
// Step 5.
var flags = ToString(rx.flags);
- // Step 2.b.iii; located here because it needs |flags|.
+ // Step 2.b.iii; located here because it needs to check |flags|.
if (!callFunction(std_String_includes, flags, "g")) {
- ThrowTypeError(JSMSG_BAD_REGEXP_FLAG, "- matchAll requires g");
+ ThrowTypeError(JSMSG_REQUIRES_GLOBAL_REGEXP, "matchAll");
}
// Step 6.