Index: wp-testcase/test_includes_wp-scripts.php
===================================================================
--- wp-testcase/test_includes_wp-scripts.php	(revision 435)
+++ wp-testcase/test_includes_wp-scripts.php	(working copy)
@@ -35,5 +35,51 @@
 		// No scripts left to print
 		$this->assertEquals("", get_echo('wp_print_scripts'));
 	}
+
+	function test_wp_localize_script_escaping() {
+		$handle = rand_str();
+		$src = 'example.com';
+		$object = rand_str();
+		$key = rand_str();
+		$key2 = rand_str();
+	
+		wp_enqueue_script( $handle, $src );
+		wp_localize_script( $handle, $object, array(
+			$key => 'abcdef\'s value',
+			$key2 => '1',
+		) );
+
+		$value = $this->_get_localized_value( $key, $key2 );
+		$this->assertEquals( '"abcdef\\\'s value"', $value );
+	}
+
+	function _get_localized_value( $key, $key2 ) {
+		$result = strip_ws( get_echo( 'wp_print_scripts' ) );
+
+		// old esc_js() looks like this:
+		// $key: "abcdef\'s value",
+
+		// json_encode() looks like this:
+		// var $handle = {"$key":"abcdef's value","$key2":"1"};
+
+		foreach ( explode( "\n", $result ) as $line ) {
+			if ( false === $pos = strpos( $line, $key ) )
+				continue;
+			$line = substr( $line, $pos + strlen( $key ) );
+			if ( 0 === strpos( $line, '"' ) )
+				$line = substr( $line, 1 );
+			if ( 0 === strpos( $line, ':' ) )
+				$line = substr( $line, 1 );
+			$line = ltrim( $line );
+			$line = rtrim( $line, ',' );
+			if ( false !== strpos( $line, $key2 ) ) {
+				list( $line ) = explode( $key2, $line );
+				if ( ',"' === substr( $line, -2 ) )
+					$line = substr( $line, 0, -2 );
+			}
+			return $line;
+		}
+	}
+
 }
 ?>
\ No newline at end of file
