Xpra: Ticket #2123: use html5 client inside an iframe

I got error if want to use Xpra html5 inside iframe element: Uncaught DOMException: Failed to read the 'sessionStorage' property from 'Window': Access is denied for this document.

Browser stopped, nothing to see. It appears in file 'Utilities.js', about in 436 line. If I catch error then everything works normally. So, the modification looks:

var value = getParameter(prop);
try {
   if (value === undefined && typeof(sessionStorage) !== undefined)
       value = sessionStorage.getItem(prop);
} catch (e) {
   // nothig to catch
}
return value;



I use Debian Stretch packages for version 2.4.3.



Sun, 27 Jan 2019 14:02:44 GMT - Dušan Vejnovič:

'nothig to catch' is a comment.


Sun, 27 Jan 2019 14:07:22 GMT - Antoine Martin: owner, description, summary changed

I would expect the connect page to also produce errors with sessionStorage access. In which case you won't be able to pass settings to the index page.

As per sessionStorage in iframe, you can use the sessionStorage if the client runs from the same domain. Maybe you can do that instead?


Tue, 29 Jan 2019 19:35:15 GMT - Dušan Vejnovič:

I cannot run xpra html5 in the same domain. What do you think about this solution: https://michalzalecki.com/why-using-localStorage-directly-is-a-bad-idea/


Wed, 30 Jan 2019 04:53:00 GMT - Antoine Martin:

Using in-memory storage won't work across pages. r21499 does merge the more thorough test for sessionStorage, so we won't try to use it when it is defined but not usable (ie: because of chrome content settings). In most cases, using URI will work the same as sessionStorage - just exposing all the settings in the URL bar, but you will not be able to use the password field of the connect page without also agreeing to use Insecure plain-text passwords settings.

Please close if that works for you.


Wed, 30 Jan 2019 09:22:35 GMT - Antoine Martin:

Oops, you also need the r21500 fixup.


Wed, 30 Jan 2019 19:53:27 GMT - Dušan Vejnovič:

You can also change 439 line in Utilities.js from

if (value === undefined && typeof(sessionStorage) !== undefined) {

to

if (value === undefined && Utilities.hasSessionStorage()) {

If you do so, xpra html5 now works in iframe without error. You may now close this ticket.


Thu, 31 Jan 2019 02:56:10 GMT - Antoine Martin: status changed; resolution set

I've gone for a slightly different solution in r21506.


Thu, 31 Jan 2019 18:40:50 GMT - Dušan Vejnovič: status changed; resolution deleted

Your solution does not work because the error is still present in line 439. So move line 439 in below try/catch block.
Example:

value = sessionStorage.getItem(prop);
try {
    if (value === undefined && typeof(sessionStorage) !== undefined) {
        value = sessionStorage.getItem(prop);
    }
}
catch (e) {
    value = null;
}
return value;

Fri, 01 Feb 2019 02:52:50 GMT - Antoine Martin:

I don't understand why javascript would throw an exception running typeof(sessionStorage), but whatever, merged in r21519. What is the error that you saw?


Fri, 01 Feb 2019 16:51:15 GMT - Dušan Vejnovič:

Replying to Antoine Martin:

I don't understand why javascript would throw an exception running typeof(sessionStorage), but whatever, merged in r21519. What is the error that you saw?

Uncaught DOMException: Failed to read the 'sessionStorage' property from 'Window': Access is denied for this document.

Fri, 01 Feb 2019 16:52:42 GMT - Antoine Martin: status changed; resolution set

Ah, thanks, got it.


Sat, 23 Jan 2021 05:42:49 GMT - migration script:

this ticket has been moved to: https://github.com/Xpra-org/xpra/issues/2123