Skip to content

Commit 1743454

Browse files
committed
fix setting of the strict mode and adjust tests
1 parent 995988b commit 1743454

1 file changed

Lines changed: 10 additions & 14 deletions

File tree

src/test/java/org/htmlunit/javascript/ScriptableObjectTest.java

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -133,30 +133,28 @@ public void ctorNotChangeableForPrimitives() throws Exception {
133133
* @throws Exception on failure
134134
*/
135135
@Test
136-
@Alerts({"TypeError", "true", "true"})
137-
@HtmlUnitNYI(CHROME = "org.htmlunit.ScriptException: TypeError: Cannot set property \"constructor\" of abc",
138-
EDGE = "org.htmlunit.ScriptException: TypeError: Cannot set property \"constructor\" of abc",
139-
FF = "org.htmlunit.ScriptException: TypeError: Cannot set property \"constructor\" of abc",
140-
FF_ESR = "org.htmlunit.ScriptException: TypeError: Cannot set property \"constructor\" of abc")
136+
@Alerts({"TypeError", "TypeError", "true", "TypeError", "true"})
141137
public void ctorNotChangeableForPrimitivesStrict() throws Exception {
142138
final String html = DOCTYPE_HTML
143139
+ "<html><body>\n"
144140
+ "<script>\n"
145-
+ LOG_TITLE_FUNCTION
146-
147141
+ " 'use strict';\n"
148-
142+
+ LOG_TITLE_FUNCTION
149143
+ " let val = null;\n"
150144
+ " try {\n"
151145
+ " val.constructor = 1;\n"
152146
+ " } catch(e) { logEx(e); }\n"
153147

154148
+ " val = 'abc';\n"
155-
+ " val.constructor = Number;"
149+
+ " try {\n"
150+
+ " val.constructor = Number;"
151+
+ " } catch(e) { logEx(e); }\n"
156152
+ " log(val.constructor === String)\n"
157153

158154
// An implicit instance of String('abc') was created and assigned the prop foo
159-
+ " val.foo = 'bar';\n"
155+
+ " try {\n"
156+
+ " val.foo = 'bar';\n"
157+
+ " } catch(e) { logEx(e); }\n"
160158
// true, since a new instance of String('abc') was created for this comparison,
161159
// which doesn't have the foo property
162160
+ " log (val.foo === undefined);\n"
@@ -215,7 +213,6 @@ public void ctorChangeableHasNoEffectForTypeOfStrict() throws Exception {
215213
+ "<script>\n"
216214
+ " 'use strict';\n"
217215
+ LOG_TITLE_FUNCTION
218-
219216
+ " let a = [];\n"
220217
+ " a.constructor = String\n"
221218
+ " log(a.constructor === String);\n"
@@ -262,7 +259,7 @@ public void ctorChangeableHasNoEffectForSealed() throws Exception {
262259
* @throws Exception on failure
263260
*/
264261
@Test
265-
@Alerts("true")
262+
@Alerts("TypeError")
266263
@HtmlUnitNYI(CHROME = "TypeError",
267264
EDGE = "TypeError",
268265
FF = "TypeError",
@@ -271,9 +268,8 @@ public void ctorChangeableHasNoEffectForSealedStrict() throws Exception {
271268
final String html = DOCTYPE_HTML
272269
+ "<html><body>\n"
273270
+ "<script>\n"
274-
+ LOG_TITLE_FUNCTION
275-
276271
+ " 'use strict';\n"
272+
+ LOG_TITLE_FUNCTION
277273

278274
+ " let a = Object.seal({});\n"
279275
+ " try {\n"

0 commit comments

Comments
 (0)