NativeError.prototype objects have [[Class]] of "Object" but should be "Error"
authorbarraclough@apple.com <barraclough@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Jul 2011 22:03:09 +0000 (22:03 +0000)
committerbarraclough@apple.com <barraclough@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Jul 2011 22:03:09 +0000 (22:03 +0000)
https://bugs.webkit.org/show_bug.cgi?id=55346

Reviewed by Sam Weinig.

Source/JavaScriptCore:

* runtime/ErrorPrototype.cpp:
(JSC::ErrorPrototype::ErrorPrototype):
    - Switch to putDirect since we're not the only ones tranitioning this Structure now.
* runtime/NativeErrorPrototype.cpp:
(JSC::NativeErrorPrototype::NativeErrorPrototype):
* runtime/NativeErrorPrototype.h:
    - Switch base class to ErrorPrototype.

LayoutTests:

Added test case.

* fast/js/native-error-prototype-expected.txt: Added.
* fast/js/native-error-prototype.html: Added.
* fast/js/script-tests/native-error-prototype.js: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/js/native-error-prototype-expected.txt [new file with mode: 0644]
LayoutTests/fast/js/native-error-prototype.html [new file with mode: 0644]
LayoutTests/fast/js/script-tests/native-error-prototype.js [new file with mode: 0644]
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/runtime/ErrorPrototype.cpp
Source/JavaScriptCore/runtime/NativeErrorPrototype.cpp
Source/JavaScriptCore/runtime/NativeErrorPrototype.h

index bb16a167c4502e7c0e6e9e66c51ce2d9ac45c12c..df1b13355980ad38a86192c88786c190e64606ba 100644 (file)
@@ -1,3 +1,16 @@
+2011-07-15  Gavin Barraclough  <barraclough@apple.com>
+
+        NativeError.prototype objects have [[Class]] of "Object" but should be "Error"
+        https://bugs.webkit.org/show_bug.cgi?id=55346
+
+        Reviewed by Sam Weinig.
+
+        Added test case.
+
+        * fast/js/native-error-prototype-expected.txt: Added.
+        * fast/js/native-error-prototype.html: Added.
+        * fast/js/script-tests/native-error-prototype.js: Added.
+
 2011-06-27  Adrienne Walker  <enne@google.com>
 
         Reviewed by Simon Fraser.
diff --git a/LayoutTests/fast/js/native-error-prototype-expected.txt b/LayoutTests/fast/js/native-error-prototype-expected.txt
new file mode 100644 (file)
index 0000000..71761bf
--- /dev/null
@@ -0,0 +1,11 @@
+This is a test case for bug 55346.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS ({}).toString.call(Error.prototype) is "[object Error]"
+PASS ({}).toString.call(RangeError.prototype) is "[object Error]"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/js/native-error-prototype.html b/LayoutTests/fast/js/native-error-prototype.html
new file mode 100644 (file)
index 0000000..060ce73
--- /dev/null
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<link rel="stylesheet" href="resources/js-test-style.css">
+<script src="resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="script-tests/native-error-prototype.js"></script>
+<script src="resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/js/script-tests/native-error-prototype.js b/LayoutTests/fast/js/script-tests/native-error-prototype.js
new file mode 100644 (file)
index 0000000..b1e0316
--- /dev/null
@@ -0,0 +1,8 @@
+description(
+'This is a test case for <a href="https://bugs.webkit.org/show_bug.cgi?id=55346">bug 55346</a>.'
+);
+
+shouldBe("({}).toString.call(Error.prototype)", '"[object Error]"');
+shouldBe("({}).toString.call(RangeError.prototype)", '"[object Error]"');
+
+var successfullyParsed = true;
index 50ff641a8e8548e77fcd6202334b08244e4c15df..4e815819ae2c4fcda54e2663de53dbe13ad5a8f3 100644 (file)
@@ -1,3 +1,18 @@
+2011-07-15  Gavin Barraclough  <barraclough@apple.com>
+
+        NativeError.prototype objects have [[Class]] of "Object" but should be "Error"
+        https://bugs.webkit.org/show_bug.cgi?id=55346
+
+        Reviewed by Sam Weinig.
+
+        * runtime/ErrorPrototype.cpp:
+        (JSC::ErrorPrototype::ErrorPrototype):
+            - Switch to putDirect since we're not the only ones tranitioning this Structure now.
+        * runtime/NativeErrorPrototype.cpp:
+        (JSC::NativeErrorPrototype::NativeErrorPrototype):
+        * runtime/NativeErrorPrototype.h:
+            - Switch base class to ErrorPrototype.
+
 2011-07-15  Gavin Barraclough  <barraclough@apple.com>
 
         DFG JIT - Where arguments passed are integers, speculate this.
index 2a513d59c7ae9ff12695098d08f77fc4916656e1..ab0f4b90d5b07656d6b575f9d2be6b94acc9c454 100644 (file)
@@ -53,7 +53,7 @@ ASSERT_CLASS_FITS_IN_CELL(ErrorPrototype);
 ErrorPrototype::ErrorPrototype(ExecState* exec, JSGlobalObject* globalObject, Structure* structure)
     : ErrorInstance(&exec->globalData(), structure)
 {
-    putDirectWithoutTransition(exec->globalData(), exec->propertyNames().name, jsNontrivialString(exec, "Error"), DontEnum);
+    putDirect(exec->globalData(), exec->propertyNames().name, jsNontrivialString(exec, "Error"), DontEnum);
 
     ASSERT(inherits(&s_info));
     putAnonymousValue(globalObject->globalData(), 0, globalObject);
index 1490720b3d4f3aaea00b3302922fc728625d5981..6830660127af32be0fb2878e409ecd482d9d281b 100644 (file)
@@ -21,7 +21,6 @@
 #include "config.h"
 #include "NativeErrorPrototype.h"
 
-#include "ErrorPrototype.h"
 #include "JSGlobalObject.h"
 #include "JSString.h"
 #include "NativeErrorConstructor.h"
@@ -32,7 +31,7 @@ namespace JSC {
 ASSERT_CLASS_FITS_IN_CELL(NativeErrorPrototype);
 
 NativeErrorPrototype::NativeErrorPrototype(ExecState* exec, JSGlobalObject* globalObject, Structure* structure, const UString& nameAndMessage, NativeErrorConstructor* constructor)
-    : JSObjectWithGlobalObject(globalObject, structure)
+    : ErrorPrototype(exec, globalObject, structure)
 {
     putDirect(exec->globalData(), exec->propertyNames().name, jsString(exec, nameAndMessage), DontEnum);
     putDirect(exec->globalData(), exec->propertyNames().message, jsString(exec, nameAndMessage), DontEnum);
index e1b05ceb82bc3f402f31d73659b3829257a10f6d..7d666b42dac7293dc2e80de101ebe5d6cfb5cad2 100644 (file)
 #ifndef NativeErrorPrototype_h
 #define NativeErrorPrototype_h
 
-#include "JSObjectWithGlobalObject.h"
+#include "ErrorPrototype.h"
 
 namespace JSC {
     class NativeErrorConstructor;
 
-    class NativeErrorPrototype : public JSObjectWithGlobalObject {
+    class NativeErrorPrototype : public ErrorPrototype {
     public:
         NativeErrorPrototype(ExecState*, JSGlobalObject*, Structure*, const UString&, NativeErrorConstructor*);
     };