aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorOleg Gaidarenko <markelog@gmail.com>2015-11-13 19:48:45 +0300
committerOleg Gaidarenko <markelog@gmail.com>2015-11-13 20:04:54 +0300
commit91acd85b167e39e05e8f4fb1be6f75cdcac9c466 (patch)
tree48c6ab809fdbfb90834563046b9096b455f4a826 /test
parent9d1d4c272a58ced36242d90b3f0462c2bbb972a3 (diff)
downloadjquery-91acd85b167e39e05e8f4fb1be6f75cdcac9c466.tar.gz
jquery-91acd85b167e39e05e8f4fb1be6f75cdcac9c466.zip
Revert "Ajax: Always use script injection in globalEval"
This reverts commit bbdfbb4ee859fe9319b348d88120ddc2c9efbd63.
Diffstat (limited to 'test')
-rw-r--r--test/data/event/longLoadScript.php (renamed from test/data/longLoadScript.php)0
-rw-r--r--test/data/event/syncReady.html2
-rw-r--r--test/unit/ajax.js14
-rw-r--r--test/unit/core.js15
-rw-r--r--test/unit/manipulation.js53
5 files changed, 30 insertions, 54 deletions
diff --git a/test/data/longLoadScript.php b/test/data/event/longLoadScript.php
index ba47168b4..ba47168b4 100644
--- a/test/data/longLoadScript.php
+++ b/test/data/event/longLoadScript.php
diff --git a/test/data/event/syncReady.html b/test/data/event/syncReady.html
index dfa9ac337..e0885707e 100644
--- a/test/data/event/syncReady.html
+++ b/test/data/event/syncReady.html
@@ -17,7 +17,7 @@ jQuery( document ).ready(function () {
oldIE into thinking the dom is ready, but it's not...
leaving this check here for future trailblazers to attempt
fixing this...-->
-<script type="text/javascript" src="../longLoadScript.php?sleep=1"></script>
+<script type="text/javascript" src="longLoadScript.php?sleep=1"></script>
<div id="container" style="height: 300px"></div>
</body>
</html>
diff --git a/test/unit/ajax.js b/test/unit/ajax.js
index 5110a9795..3d3bfb9aa 100644
--- a/test/unit/ajax.js
+++ b/test/unit/ajax.js
@@ -1624,9 +1624,17 @@ if ( typeof window.ArrayBuffer === "undefined" || typeof new XMLHttpRequest().re
jQuery.ajax( {
url: "data/badjson.js",
dataType: "script",
- throws: true
- } );
- } );
+ throws: true,
+ // Global events get confused by the exception
+ global: false,
+ success: function() {
+ ok( false, "Success." );
+ },
+ error: function() {
+ ok( false, "Error." );
+ }
+ });
+ });
jQuery.each( [ "method", "type" ], function( _, globalOption ) {
function request( assert, option ) {
diff --git a/test/unit/core.js b/test/unit/core.js
index 33a98cedc..6aa2a3d63 100644
--- a/test/unit/core.js
+++ b/test/unit/core.js
@@ -170,21 +170,6 @@ QUnit.test( "globalEval with 'use strict'", function( assert ) {
assert.equal( window.strictEvalTest, 1, "Test variable declarations are global (strict mode)" );
} );
-QUnit.test( "globalEval execution after script injection (#7862)", function( assert ) {
- assert.expect( 1 );
-
- var now,
- script = document.createElement( "script" );
-
- script.src = "data/longLoadScript.php?sleep=2";
-
- now = jQuery.now();
- document.body.appendChild( script );
-
- jQuery.globalEval( "var strictEvalTest = " + jQuery.now() + ";" );
- assert.ok( window.strictEvalTest - now < 500, "Code executed synchronously" );
-} );
-
// This is not run in AMD mode
if ( jQuery.noConflict ) {
QUnit.test( "noConflict", function( assert ) {
diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js
index 2069ee5c5..e62eae16b 100644
--- a/test/unit/manipulation.js
+++ b/test/unit/manipulation.js
@@ -2297,45 +2297,28 @@ QUnit.test( "Ensure oldIE creates a new set on appendTo (#8894)", function( asse
assert.strictEqual( jQuery( "<p/>" ).appendTo( "<div/>" ).end().length, jQuery( "<p>test</p>" ).appendTo( "<div/>" ).end().length, "Elements created with createElement and with createDocumentFragment should be treated alike" );
} );
-QUnit.asyncTest( "html() - script exceptions bubble (#11743)", 2, function( assert ) {
+QUnit.test( "html() - script exceptions bubble (#11743)", function( assert ) {
+ assert.expect( 3 );
- // Support: Android 2.3 only
- // Android 2.3 doesn't fire the window.onerror handler, just accept the reality there.
- if ( /android 2\.3/i.test( navigator.userAgent ) ) {
- assert.ok( true, "Test skipped, Android 2.3 doesn't fire window.onerror for " +
- "errors in dynamically included scripts" );
- assert.ok( true, "Test skipped, Android 2.3 doesn't fire window.onerror for " +
- "errors in dynamically included scripts" );
- QUnit.start();
- return;
- }
+ assert.throws(function() {
+ jQuery("#qunit-fixture").html("<script>undefined(); ok( false, 'Exception not thrown' );</script>");
+ assert.ok( false, "Exception ignored" );
+ }, "Exception bubbled from inline script" );
- var onerror = window.onerror;
+ if ( jQuery.ajax ) {
+ var onerror = window.onerror;
+ window.onerror = function() {
+ ok( true, "Exception thrown in remote script" );
+ };
- setTimeout( function() {
+ jQuery("#qunit-fixture").html("<script src='data/badcall.js'></script>");
+ assert.ok( true, "Exception ignored" );
window.onerror = onerror;
-
- QUnit.start();
- }, 1000 );
-
- window.onerror = function() {
- assert.ok( true, "Exception thrown" );
-
- if ( jQuery.ajax ) {
- window.onerror = function() {
- assert.ok( true, "Exception thrown in remote script" );
- };
-
- jQuery( "#qunit-fixture" ).html( "<script src='data/badcall.js'></script>" );
- assert.ok( true, "Exception ignored" );
- } else {
- assert.ok( true, "No jQuery.ajax" );
- assert.ok( true, "No jQuery.ajax" );
- }
- };
-
- jQuery( "#qunit-fixture" ).html( "<script>undefined();</script>" );
-} );
+ } else {
+ assert.ok( true, "No jQuery.ajax" );
+ assert.ok( true, "No jQuery.ajax" );
+ }
+});
QUnit.test( "checked state is cloned with clone()", function( assert ) {