Browse Source

Add spec for alert/confirm toString errors

Kevin Sawicki 8 years ago
parent
commit
a00d36fb07
1 changed files with 24 additions and 0 deletions
  1. 24 0
      spec/chromium-spec.js

+ 24 - 0
spec/chromium-spec.js

@@ -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/)
+    })
+  })
 })