Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 22 additions & 4 deletions dev/codeserver/java/com/google/gwt/dev/codeserver/stub.nocache.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,19 @@
(function($wnd, $doc){
// Compute some codeserver urls so as the user does not need bookmarklets
var hostName = $wnd.location.hostname;
var serverUrl = 'http://' + hostName + ':__SUPERDEV_PORT__';
var module = '__MODULE_NAME__';

// The default Super Dev Mode server url. The user may override it (and retry)
// through the prompt shown by the error handler below; the override is kept
// for the session so the reload picks up the new server.
var serverUrlKey = '__gwt_sdm__server_url';
var defaultServerUrl = 'http://' + hostName + ':__SUPERDEV_PORT__';
var serverUrl = defaultServerUrl;
try {
serverUrl = $wnd.sessionStorage.getItem(serverUrlKey) || defaultServerUrl;
} catch (e) {
// sessionStorage may be unavailable; fall back to the default url.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the risk/likelihood that session storage is unavailable? dev_mode_on.js relies on it and won't function without it, so I think maybe we can assume it is there?

}
var nocacheUrl = serverUrl + '/recompile-requester/' + module;

// Insert the superdevmode nocache script in the first position of the head
Expand All @@ -32,15 +43,22 @@
// This means that we do not detect a non running SDM with IE8.
if (devModeScript.addEventListener) {
var callback = function() {
// Don't show the confirmation dialogue twice (multimodule)
// Don't show the prompt twice (multimodule)
if (!$wnd.__gwt__sdm__confirmed &&
(!$wnd.__gwt_sdm__recompiler || !$wnd.__gwt_sdm__recompiler.loaded)) {
$wnd.__gwt__sdm__confirmed = true;
if ($wnd.confirm(
var newServerUrl = $wnd.prompt(
"Couldn't load " + module + " from Super Dev Mode\n" +
"server at " + serverUrl + ".\n" +
"Please make sure this server is ready.\n" +
"Do you want to try again?")) {
"Press OK to try again:",
serverUrl);
if (newServerUrl) {
try {
$wnd.sessionStorage.setItem(serverUrlKey, newServerUrl);
} catch (e) {
// Without storage the reload falls back to the default url.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(assuming still relevant) Should probably notify that the prompt had no effect?

Maybe test for storage usage before attempting to use prompt to begin with?

}
$wnd.location.reload();
}
}
Expand Down