|
17 | 17 |
|
18 | 18 | /** |
19 | 19 | * Test that exception messages contain rich information. |
20 | | - * Unit tests for <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=604674">bug 604674</a>. |
| 20 | + * |
21 | 21 | * @author Marc Guillemot |
| 22 | + * @author Ronald Brill |
22 | 23 | */ |
23 | 24 | public class ExceptionMessageTest { |
24 | 25 |
|
@@ -60,67 +61,4 @@ public Object run(final Context cx) { |
60 | 61 |
|
61 | 62 | Utils.runWithAllOptimizationLevels(action); |
62 | 63 | } |
63 | | - |
64 | | - /** |
65 | | - * Unit test for bug 604674 |
66 | | - * https://bugzilla.mozilla.org/show_bug.cgi?id=604674 |
67 | | - */ |
68 | | - @Test |
69 | | - public void onlyGetterError() { |
70 | | - onlyGetterError(Context.FEATURE_STRICT_MODE); |
71 | | - } |
72 | | - |
73 | | - private static void onlyGetterError(final int feature) { |
74 | | - final ContextFactory cf = new ContextFactory() { |
75 | | - @Override |
76 | | - protected boolean hasFeature(Context cx, int featureIndex) { |
77 | | - if (Context.FEATURE_STRICT_MODE == featureIndex) { |
78 | | - return true; |
79 | | - } |
80 | | - return super.hasFeature(cx, featureIndex); |
81 | | - } |
82 | | - }; |
83 | | - |
84 | | - final String script = "o.readonlyProp = 123"; |
85 | | - |
86 | | - final ContextAction<Object> action = new ContextAction<Object>() { |
87 | | - @Override |
88 | | - public Object run(final Context cx) { |
89 | | - try { |
90 | | - Scriptable scope = cx.initSafeStandardObjects(); |
91 | | - final MyHostObject prototype = new MyHostObject(); |
92 | | - ScriptableObject.defineClass(scope, MyHostObject.class); |
93 | | - final Method readMethod = MyHostObject.class.getMethod("jsxGet_x"); |
94 | | - prototype.defineProperty("readonlyProp", null, readMethod , null, ScriptableObject.EMPTY); |
95 | | - |
96 | | - ScriptableObject.defineProperty(scope, "o", prototype, ScriptableObject.DONTENUM); |
97 | | - |
98 | | - cx.evaluateString(scope, script, "test_script", 1, null); |
99 | | - throw new RuntimeException("Should have failed!"); |
100 | | - } |
101 | | - catch (final EcmaError e) { |
102 | | - assertEquals("TypeError: Cannot set property [MyHostObject].readonlyProp that has only a getter to value '123'. (test_script#1)", e.getMessage()); |
103 | | - return null; |
104 | | - } |
105 | | - catch (final Exception e) { |
106 | | - throw new RuntimeException(e); |
107 | | - } |
108 | | - } |
109 | | - }; |
110 | | - |
111 | | - Utils.runWithAllOptimizationLevels(cf, action); |
112 | | - } |
113 | | - |
114 | | - public static class MyHostObject extends ScriptableObject { |
115 | | - private int x; |
116 | | - |
117 | | - @Override |
118 | | - public String getClassName() { |
119 | | - return getClass().getSimpleName(); |
120 | | - } |
121 | | - |
122 | | - public int jsxGet_x() { |
123 | | - return x; |
124 | | - } |
125 | | - } |
126 | 64 | } |
0 commit comments