Add spec for alert/confirm toString errors
authorKevin Sawicki <kevinsawicki@gmail.com>
Fri, 21 Apr 2017 19:19:37 +0000 (12:19 -0700)
committerKevin Sawicki <kevinsawicki@gmail.com>
Mon, 24 Apr 2017 16:15:01 +0000 (09:15 -0700)
spec/chromium-spec.js

index 6a5937b..4c5b855 100644 (file)
@@ -880,4 +880,28 @@ describe('chromium feature', function () {
       })
     })
   })
+
+  describe('window.alert(message, title)', function () {
+    it('throws an exception when the arguments cannot be converted to strings', function () {
+      assert.throws(function () {
+        window.alert({toString: null})
+      }, /Cannot convert object to primitive value/)
+
+      assert.throws(function () {
+        window.alert('message', {toString: 3})
+      }, /Cannot convert object to primitive value/)
+    })
+  })
+
+  describe('window.confirm(message, title)', function () {
+    it('throws an exception when the arguments cannot be converted to strings', function () {
+      assert.throws(function () {
+        window.confirm({toString: null}, 'title')
+      }, /Cannot convert object to primitive value/)
+
+      assert.throws(function () {
+        window.confirm('message', {toString: 3})
+      }, /Cannot convert object to primitive value/)
+    })
+  })
 })