summaryrefslogtreecommitdiff
path: root/Libraries/LibWeb/Bindings/WindowObject.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-05-15 13:39:24 +0200
committerAndreas Kling <kling@serenityos.org>2020-05-15 13:50:42 +0200
commitc6ddbd1f3ec30ccf7dc150f5a0eff982bd411293 (patch)
tree58897d645f1adcbbebd14569b9be555305f8382f /Libraries/LibWeb/Bindings/WindowObject.cpp
parentd8aa2a6997800779cd2dc4303cb2256a32ffc2f3 (diff)
downloadserenity-c6ddbd1f3ec30ccf7dc150f5a0eff982bd411293.zip
LibJS: Add side-effect-free version of Value::to_string()
There are now two API's on Value: - Value::to_string(Interpreter&) -- may throw. - Value::to_string_without_side_effects() -- will never throw. These are some pretty big sweeping changes, so it's possible that I did some part the wrong way. We'll work it out as we go. :^) Fixes #2123.
Diffstat (limited to 'Libraries/LibWeb/Bindings/WindowObject.cpp')
-rw-r--r--Libraries/LibWeb/Bindings/WindowObject.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/Libraries/LibWeb/Bindings/WindowObject.cpp b/Libraries/LibWeb/Bindings/WindowObject.cpp
index bab0a17316..1c1dcedce4 100644
--- a/Libraries/LibWeb/Bindings/WindowObject.cpp
+++ b/Libraries/LibWeb/Bindings/WindowObject.cpp
@@ -98,8 +98,11 @@ JS::Value WindowObject::alert(JS::Interpreter& interpreter)
if (!impl)
return {};
String message = "";
- if (interpreter.argument_count())
- message = interpreter.argument(0).to_string();
+ if (interpreter.argument_count()) {
+ message = interpreter.argument(0).to_string(interpreter);
+ if (interpreter.exception())
+ return {};
+ }
impl->alert(message);
return JS::js_undefined();
}
@@ -110,8 +113,11 @@ JS::Value WindowObject::confirm(JS::Interpreter& interpreter)
if (!impl)
return {};
String message = "";
- if (interpreter.argument_count())
- message = interpreter.argument(0).to_string();
+ if (interpreter.argument_count()) {
+ message = interpreter.argument(0).to_string(interpreter);
+ if (interpreter.exception())
+ return {};
+ }
return JS::Value(impl->confirm(message));
}