Skip to main content

Bug Tracker

Side navigation

#8166 closed bug (wontfix)

Opened February 03, 2011 05:16PM UTC

Closed February 04, 2011 12:39AM UTC

Last modified March 13, 2012 05:29PM UTC

$.getScript: sameDomain file:// requests fails in Chromium when using XHR

Reported by: ast@mugami.com Owned by: jaubourg
Priority: low Milestone: 1.5.1
Component: ajax Version: 1.5
Keywords: Cc:
Blocked by: Blocking:
Description

When doing same-domain file:// XHR Chromium spits out an

XMLHttpRequest cannot load file://[...].js.
Origin null is not allowed by Access-Control-Allow-Origin.

The following patch is pullable from: git://git.asbjorn.biz/jquery.git getscript-fix

ajax: script: Threat sameDomain file:// requests as crossDomain

Due to file:// XHR security measures in Chromium, dynamic loading
of scripts need to use the script tag injection hack.

Tested in Chromium 6.0.472.63, Firefox 3.6.7 and Konqueror 4.4.5

Signed-off-by: Asbjørn Sloth Tønnesen <ast@mugami.com>
diff --git a/src/ajax/script.js b/src/ajax/script.js
index 34ddd04..c80696c 100644
--- a/src/ajax/script.js
+++ b/src/ajax/script.js
@@ -30,8 +30,11 @@ jQuery.ajaxPrefilter( "script", function( s ) {
 // Bind script tag hack transport
 jQuery.ajaxTransport( "script", function(s) {
 
-	// This transport only deals with cross domain requests
-	if ( s.crossDomain ) {
+	// This transport primarily deals with cross domain requests
+	// but also sameDomain request within file:// due to
+	// http://code.google.com/p/chromium/issues/detail?id=4197 + 47416
+	var local = location.protocol === 'file:'
+	if ( s.crossDomain || local ) {
 
 		var script,
 			head = document.head || document.getElementsByTagName( "head" )[0] || document.documentElement;

Related issues in Chromiums issue tracker:

Attachments (0)
Change History (8)

Changed February 03, 2011 05:37PM UTC by rwaldron comment:1

component: unfiledajax
priority: undecidedhigh
resolution: → duplicate
status: newclosed

Changed February 03, 2011 05:37PM UTC by rwaldron comment:2

Duplicate of #8125.

Changed February 03, 2011 06:04PM UTC by jitter comment:3

milestone: 1.next1.5.1
version: git1.5

Changed February 03, 2011 07:33PM UTC by asbjornbiz comment:4

This is not a duplicate of #8125, that was fixed in git two days ago, my bug report was against git, not 1.5.

Testcases based on current git HEAD and HEAD+fix: http://asbjorn.it/pub/bugreports/jquery/6166-testcase.tar.bz2 to be run from local file:// context.

BTW: The patch had a minor error which has been fixed in git://git.asbjorn.biz/jquery.git getscript-fix

Changed February 03, 2011 11:38PM UTC by jitter comment:5

resolution: duplicate
status: closedreopened

Changed February 03, 2011 11:39PM UTC by jitter comment:6

owner: → jaubourg
status: reopenedassigned

Changed February 04, 2011 12:39AM UTC by jitter comment:7

_comment0: If you wanna make sure every script requests are considered cross-domain, add the following prefilter: \ {{{ \ jQuery.ajaxPrefilter( "script", function( s ) { \ s.crossDomain = true; \ } ); \ }}}1296780502412086
priority: highlow
resolution: → wontfix
status: assignedclosed

If you wanna make sure every script requests are considered cross-domain, add the following prefilter:

jQuery.ajaxPrefilter( "script", function( s ) {
    s.crossDomain = true;
} );

Changed February 11, 2011 02:58PM UTC by jitter comment:8

#8249 is a duplicate of this ticket.