Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SDM (dev_mode_on.js) to work with strong CSP #9952

Merged
merged 6 commits into from
Jun 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 14 additions & 3 deletions dev/codeserver/java/com/google/gwt/dev/codeserver/dev_mode_on.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,15 @@
return dialog;
}

function makeBookmarklet(name, javascript) {
function makeBookmarklet(name, javascript, javascriptFunction) {
lgemeinhardt marked this conversation as resolved.
Show resolved Hide resolved
var result = makeTextElt('a', '12pt', name);
result.style.fontFamily = 'sans';
result.style.textDecoration = 'none';
result.style.background = '#ddd';
result.style.border = '2px outset #ddd';
result.style.padding = '3pt';
result.setAttribute('href', 'javascript:' + encodeURIComponent(javascript));
result.onclick = javascriptFunction; // used in CSP case (clicking the button)
result.setAttribute('href', 'javascript:' + encodeURIComponent(javascript)); // used in bookmarklet case
result.title = 'Tip: drag this button to the bookmark bar';
return result;
}
Expand All @@ -135,7 +136,17 @@
+ ' var s = document.createElement(\'script\');'
+ ' s.src = \'' + bookmarklets_js + '\';'
+ ' void(document.getElementsByTagName(\'head\')[0].appendChild(s));}';
return makeBookmarklet('Compile', javascript);
var javascriptFunction = function(e) {
e.preventDefault(); // avoid CSP warning
window.__gwt_bookmarklet_params = {
server_url: codeserver_url,
module_name: module_name
};
var s = document.createElement('script');
s.src = bookmarklets_js;
void(document.getElementsByTagName('head')[0].appendChild(s));
};
return makeBookmarklet('Compile', javascript, javascriptFunction);
}

/**
Expand Down