Set#keys !== Set#values
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 26 Apr 2015 01:08:59 +0000 (01:08 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 26 Apr 2015 01:08:59 +0000 (01:08 +0000)
https://bugs.webkit.org/show_bug.cgi?id=144190

Patch by Jordan Harband <ljharb@gmail.com> on 2015-04-25
Reviewed by Darin Adler.

Source/JavaScriptCore:

per https://people.mozilla.org/~jorendorff/es6-draft.html#sec-set.prototype.keys
Set#keys should === Set#values

* runtime/SetPrototype.cpp:
(JSC::SetPrototype::finishCreation):
(JSC::setProtoFuncValues):
(JSC::setProtoFuncEntries):
(JSC::setProtoFuncKeys): Deleted.

LayoutTests:

* js/script-tests/set-keys.js: Added.
* js/set-keys-expected.txt: Added.
* js/set-keys.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@183320 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/js/script-tests/set-keys.js [new file with mode: 0644]
LayoutTests/js/set-keys-expected.txt [new file with mode: 0644]
LayoutTests/js/set-keys.html [new file with mode: 0644]
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/SetPrototype.cpp

index 03deb21..865b0e3 100644 (file)
@@ -1,3 +1,14 @@
+2015-04-25  Jordan Harband  <ljharb@gmail.com>
+
+        Set#keys !== Set#values
+        https://bugs.webkit.org/show_bug.cgi?id=144190
+
+        Reviewed by Darin Adler.
+
+        * js/script-tests/set-keys.js: Added.
+        * js/set-keys-expected.txt: Added.
+        * js/set-keys.html: Added.
+
 2015-04-25  Darin Adler  <darin@apple.com>
 
         Crash if IDBTransaction is aborted right after it's created
diff --git a/LayoutTests/js/script-tests/set-keys.js b/LayoutTests/js/script-tests/set-keys.js
new file mode 100644 (file)
index 0000000..caf4641
--- /dev/null
@@ -0,0 +1,4 @@
+description("Tests basic correctness of ES Set's keys() API");
+
+shouldBe("Set.prototype.keys.length", "0");
+shouldBeTrue("Set.prototype.keys === Set.prototype.values");
diff --git a/LayoutTests/js/set-keys-expected.txt b/LayoutTests/js/set-keys-expected.txt
new file mode 100644 (file)
index 0000000..32a3488
--- /dev/null
@@ -0,0 +1,11 @@
+Tests basic correctness of ES Set's keys() API
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS Set.prototype.keys.length is 0
+PASS Set.prototype.keys === Set.prototype.values is true
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/js/set-keys.html b/LayoutTests/js/set-keys.html
new file mode 100644 (file)
index 0000000..90768eb
--- /dev/null
@@ -0,0 +1,10 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="script-tests/set-keys.js"></script>
+<script src="../resources/js-test-post.js"></script>
+</body>
+</html>
index f97f276..918ff50 100644 (file)
@@ -1,3 +1,19 @@
+2015-04-25  Jordan Harband  <ljharb@gmail.com>
+
+        Set#keys !== Set#values
+        https://bugs.webkit.org/show_bug.cgi?id=144190
+
+        Reviewed by Darin Adler.
+
+        per https://people.mozilla.org/~jorendorff/es6-draft.html#sec-set.prototype.keys
+        Set#keys should === Set#values
+
+        * runtime/SetPrototype.cpp:
+        (JSC::SetPrototype::finishCreation):
+        (JSC::setProtoFuncValues):
+        (JSC::setProtoFuncEntries):
+        (JSC::setProtoFuncKeys): Deleted.
+
 2015-04-25  Joseph Pecoraro  <pecoraro@apple.com>
 
         Allow for pausing a JSContext when opening a Web Inspector
index 6a21c37..e6d5259 100644 (file)
@@ -46,7 +46,6 @@ static EncodedJSValue JSC_HOST_CALL setProtoFuncClear(ExecState*);
 static EncodedJSValue JSC_HOST_CALL setProtoFuncDelete(ExecState*);
 static EncodedJSValue JSC_HOST_CALL setProtoFuncForEach(ExecState*);
 static EncodedJSValue JSC_HOST_CALL setProtoFuncHas(ExecState*);
-static EncodedJSValue JSC_HOST_CALL setProtoFuncKeys(ExecState*);
 static EncodedJSValue JSC_HOST_CALL setProtoFuncValues(ExecState*);
 static EncodedJSValue JSC_HOST_CALL setProtoFuncEntries(ExecState*);
 
@@ -64,11 +63,11 @@ void SetPrototype::finishCreation(VM& vm, JSGlobalObject* globalObject)
     JSC_NATIVE_FUNCTION(vm.propertyNames->deleteKeyword, setProtoFuncDelete, DontEnum, 1);
     JSC_NATIVE_FUNCTION(vm.propertyNames->forEach, setProtoFuncForEach, DontEnum, 1);
     JSC_NATIVE_FUNCTION(vm.propertyNames->has, setProtoFuncHas, DontEnum, 1);
-    JSC_NATIVE_FUNCTION(vm.propertyNames->keys, setProtoFuncKeys, DontEnum, 0);
     JSC_NATIVE_FUNCTION(vm.propertyNames->entries, setProtoFuncEntries, DontEnum, 0);
 
     JSFunction* values = JSFunction::create(vm, globalObject, 0, vm.propertyNames->values.string(), setProtoFuncValues);
     putDirectWithoutTransition(vm, vm.propertyNames->values, values, DontEnum);
+    putDirectWithoutTransition(vm, vm.propertyNames->keys, values, DontEnum);
     putDirectWithoutTransition(vm, vm.propertyNames->iteratorSymbol, values, DontEnum);
 
     GetterSetter* accessor = GetterSetter::create(vm, globalObject);
@@ -172,7 +171,7 @@ EncodedJSValue JSC_HOST_CALL setProtoFuncValues(CallFrame* callFrame)
 {
     JSSet* thisObj = jsDynamicCast<JSSet*>(callFrame->thisValue());
     if (!thisObj)
-        return JSValue::encode(throwTypeError(callFrame, ASCIILiteral("Cannot create a Map value iterator for a non-Map object.")));
+        return JSValue::encode(throwTypeError(callFrame, ASCIILiteral("Cannot create a Set value iterator for a non-Set object.")));
     return JSValue::encode(JSSetIterator::create(callFrame->vm(), callFrame->callee()->globalObject()->setIteratorStructure(), thisObj, SetIterateValue));
 }
 
@@ -180,16 +179,8 @@ EncodedJSValue JSC_HOST_CALL setProtoFuncEntries(CallFrame* callFrame)
 {
     JSSet* thisObj = jsDynamicCast<JSSet*>(callFrame->thisValue());
     if (!thisObj)
-        return JSValue::encode(throwTypeError(callFrame, ASCIILiteral("Cannot create a Map key iterator for a non-Map object.")));
+        return JSValue::encode(throwTypeError(callFrame, ASCIILiteral("Cannot create a Set key iterator for a non-Set object.")));
     return JSValue::encode(JSSetIterator::create(callFrame->vm(), callFrame->callee()->globalObject()->setIteratorStructure(), thisObj, SetIterateKeyValue));
 }
 
-EncodedJSValue JSC_HOST_CALL setProtoFuncKeys(CallFrame* callFrame)
-{
-    JSSet* thisObj = jsDynamicCast<JSSet*>(callFrame->thisValue());
-    if (!thisObj)
-        return JSValue::encode(throwTypeError(callFrame, ASCIILiteral("Cannot create a Map entry iterator for a non-Map object.")));
-    return JSValue::encode(JSSetIterator::create(callFrame->vm(), callFrame->callee()->globalObject()->setIteratorStructure(), thisObj, SetIterateKey));
-}
-
 }