Adding client side check of setVariable with writableBy property

This commit is contained in:
David Négrier 2021-07-06 10:58:12 +02:00
parent 86fa869b20
commit cb78ff333b
5 changed files with 95 additions and 11 deletions

View file

@ -7,9 +7,14 @@ WA.onInit().then(() => {
console.log('Successfully caught error: ', e);
});
console.log('Trying to set variable "config". This should work.');
WA.room.saveVariable('config', {'foo': 'bar'});
console.log('Trying to set variable "myvar". This should work.');
WA.room.saveVariable('myvar', {'foo': 'bar'});
console.log('Trying to read variable "config". This should display a {"foo": "bar"} object.');
console.log(WA.room.loadVariable('config'));
console.log('Trying to read variable "myvar". This should display a {"foo": "bar"} object.');
console.log(WA.room.loadVariable('myvar'));
console.log('Trying to set variable "config". This should not work because we are not logged as admin.');
WA.room.saveVariable('config', {'foo': 'bar'}).catch(e => {
console.log('Successfully caught error because variable "config" is not writable: ', e);
});
});