diff --git a/tests/browser_test.mjs b/tests/browser_test.mjs
index 5ea3f5e..2f2bdda 100644
--- a/tests/browser_test.mjs
+++ b/tests/browser_test.mjs
@@ -93,6 +93,12 @@ try{
assert.deepEqual(await site.eval(`({items:pedido.length,empty:!$('carrVazio').hidden||document.documentElement.hasAttribute('data-sem-itens'),undo:!$('desfazer').hidden})`),{items:0,empty:true,undo:true});
await site.click('#desfazerBtn');
assert.equal(await site.eval('pedido.length===1 && pedido[0].total===21.89 && $("desfazer").hidden'),true);
+ // The items come back after a reload; the customer's details do not.
+ assert.deepEqual(await site.eval(`['fCnpj','fZap','fMail'].map(id=>$(id).value)`),['','','']);
+ assert.equal(await site.eval('document.getElementById("bPagar").disabled'),true);
+ await site.fill('#fCnpj','11222333000181');
+ await site.fill('#fZap','11999999999');
+ await site.fill('#fMail','local-browser@example.test');
assert.equal(await site.eval('pedido[0].localFiles[0].name'),'local-test.cdr');
assert.equal(await site.eval('pedido[0].total'),21.89);
assert.equal(await site.eval('document.getElementById("bPagar").disabled'),false);
diff --git a/web/cart.js b/web/cart.js
index f335ca9..430b0c2 100644
--- a/web/cart.js
+++ b/web/cart.js
@@ -1,5 +1,11 @@
-/* Browser-local cart recovery. Files are stored only for an unfinished cart, for 24h. */
+/* Browser-local cart recovery. Files are stored only for an unfinished cart, for 24h.
+ Only the items are kept: the customer's details and address are typed again
+ after a reload or a closed tab, so nothing personal stays in the browser. */
(() => {
+ // A browser may put back what was typed before the reload without telling
+ // the page, which then shows values it does not know and cannot pay with.
+ const CAMPOS=['fCnpj','fZap','fMail','cepIn','eNome','eRua','eNum','eComp','eBairro','eCidade','eUf'];
+ for(const id of CAMPOS)if($(id))$(id).value='';
let database,scope,timer,restoring=true;
let signedOut=false;
window.addEventListener('dtf-private-data-cleared',()=>{signedOut=true;clearTimeout(timer);pedido=[];itemAtual=null;folhas=[];artes=[];});
@@ -11,7 +17,7 @@
const items=[...pedido,...(itemAtual?[itemAtual]:[])];
try{
if(!items.length){await transaction('readwrite',store=>store.delete(scope));return;}
- await transaction('readwrite',store=>store.put({items,customer:{...cliente},delivery:{...entrega},expires:Date.now()+86400000},scope));
+ await transaction('readwrite',store=>store.put({items,expires:Date.now()+86400000},scope));
notice.textContent='Carrinho salvo neste navegador por 24 horas. Você pode remover itens e adicionar outros após recarregar.';
}catch(error){notice.textContent='Não foi possível salvar o carrinho neste navegador. Mantenha esta página aberta até enviar o pedido.';}
}
@@ -30,16 +36,8 @@
for(const key of records){const value=await transaction('readonly',store=>store.get(key));if(value.expires