Skip to content

Commit c31f95f

Browse files
author
Christian Krebs
committed
DFL-3478 Using Dragonfly from file:// with XHR throws in Settings > About
1 parent 21bd69b commit c31f95f

File tree

4 files changed

+34
-12
lines changed

4 files changed

+34
-12
lines changed

src/ecma-debugger/views.js

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,17 +79,29 @@ cls.AboutView.create_ui_widgets = function()
7979
about:
8080
function(setting)
8181
{
82-
new XMLHttpRequest().loadResource('AUTHORS', function(xml)
82+
var on_about_sucess = function(xml)
8383
{
84-
var
85-
authors = document.getElementById('about-authors'),
86-
response_text = xml.responseText;
87-
if(authors && response_text)
88-
{
84+
var authors = document.getElementById('about-authors');
85+
var response_text = xml.responseText;
86+
if (authors && response_text)
8987
authors.textContent = response_text;
88+
};
89+
90+
var on_about_error = function()
91+
{
92+
var authors = document.getElementById('about-authors');
93+
if (authors)
94+
{
95+
var tmpl = ["a", ui_strings.S_CONTRIBUTORS,
96+
"target", "_blank",
97+
"style", "color: inherit",
98+
"href", "https://github.com/operasoftware/dragonfly/blob/master/AUTHORS"];
99+
authors.render(tmpl);
90100
}
91-
});
92-
return ['ul', ['li', 'id', 'about-authors', 'class', 'padding selectable']];
101+
};
102+
103+
new XMLHttpRequest().loadResource("AUTHORS", on_about_sucess, null, on_about_error);
104+
return ["ul", ["li", "id", "about-authors", "class", "padding selectable"]];
93105
}
94106
},
95107
"about"

src/lib/usertracker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ cls.UserTracker = function(url, storagekey)
3131

3232
conn.onreadystatechange = rshandler;
3333
conn.open("GET", url, true);
34-
conn.send(null);
34+
try { conn.send(null); } catch(e) {};
3535
}
3636

3737

src/lib/xmlhttprequestprototype.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,18 @@
55
* "this" value
66
*/
77

8-
XMLHttpRequest.prototype.loadResource = function(url, callback, context)
8+
XMLHttpRequest.prototype.loadResource = function(url, callback, context, error_callback)
99
{
1010
this.onload = function()
1111
{
1212
callback(this, context);
13-
}
13+
};
14+
15+
this.onerror = function()
16+
{
17+
setTimeout(error_callback, 0, context);
18+
};
19+
1420
this.open('GET', url);
15-
this.send(null);
21+
try { this.send(null); } catch(e) {};
1622
};

src/ui-strings/ui_strings-en.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1746,3 +1746,7 @@ ui_strings.S_TOGGLE_PAUSED_UPDATING_NETWORK_VIEW = "Pause updating network activ
17461746
/* DESC: String shown instead of filename when file name is missing */
17471747
ui_strings.S_UNKNOWN_SCRIPT = "(Unknown script)";
17481748

1749+
/* DESC: Text for a link to the contributors list. */
1750+
ui_strings.S_CONTRIBUTORS = "Contributors";
1751+
1752+

0 commit comments

Comments
 (0)