aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/test/ujs
diff options
context:
space:
mode:
authorDmytro Vasin <dmytro.vasin@gmail.com>2017-04-13 16:58:36 +0300
committerDmytro Vasin <dmytro.vasin@gmail.com>2017-04-13 16:58:36 +0300
commitdb65f73f2e442eb87228f604d28af2548e7dd823 (patch)
treebf9c646a447ef8d1e144652bed5f6ee821778794 /actionview/test/ujs
parentfaca40dfd4032bbe2373210255eb7aa1c6527503 (diff)
downloadrails-db65f73f2e442eb87228f604d28af2548e7dd823.tar.gz
rails-db65f73f2e442eb87228f604d28af2548e7dd823.tar.bz2
rails-db65f73f2e442eb87228f604d28af2548e7dd823.zip
Fix mistake in JS response parser:
- Restore ability to accept ecmascript JS response should not modify DOM.
Diffstat (limited to 'actionview/test/ujs')
-rw-r--r--actionview/test/ujs/public/test/call-remote.js28
1 files changed, 28 insertions, 0 deletions
diff --git a/actionview/test/ujs/public/test/call-remote.js b/actionview/test/ujs/public/test/call-remote.js
index dbeb8ad832..5932195363 100644
--- a/actionview/test/ujs/public/test/call-remote.js
+++ b/actionview/test/ujs/public/test/call-remote.js
@@ -100,6 +100,34 @@ asyncTest('JS code should be executed', 1, function() {
submit()
})
+asyncTest('ecmascript code should be executed', 1, function() {
+ buildForm({ method: 'post', 'data-type': 'script' })
+
+ $('form').append('<input type="text" name="content_type" value="application/ecmascript">')
+ $('form').append('<input type="text" name="content" value="ok(true, \'remote code should be run\')">')
+
+ submit()
+})
+
+asyncTest('execution of JS code does not modify current DOM', 1, function() {
+ var docLength, newDocLength
+ function getDocLength() {
+ return document.documentElement.outerHTML.length
+ }
+
+ buildForm({ method: 'post', 'data-type': 'script' })
+
+ $('form').append('<input type="text" name="content_type" value="text/javascript">')
+ $('form').append('<input type="text" name="content" value="\'remote code should be run\'">')
+
+ docLength = getDocLength()
+
+ submit(function() {
+ newDocLength = getDocLength()
+ ok(docLength === newDocLength, 'executed JS should not present in the document')
+ })
+})
+
asyncTest('XML document should be parsed', 1, function() {
buildForm({ method: 'post', 'data-type': 'html' })