openvibers/openvibe.network Commits

footer: define the global root it shares the chrome cache through; test that every browser bundle evaluates

OP OpenVibers committed 18 Sept 2026 · 19ac055117 · 2 files, +17 −0


Changes

ddiff --git a/packages/openvibe-shared/footer.js b/packages/openvibe-shared/footer.js
iindex abc1fd6d..ec7ce0e4 100644
---- a/packages/openvibe-shared/footer.js
++++ b/packages/openvibe-shared/footer.js
@@@ -27,6 +27,7 @@
})(typeof globalThis !== 'undefined' ? globalThis : this, function () {
'use strict';
++ const root = typeof globalThis !== 'undefined' ? globalThis : (typeof window !== 'undefined' ? window : {});
// ── Shared chrome data (https://openvibe.network/api/chrome) ─────────────────────────────
// Sites ordered by real use, footer copy and per-site legal links. Cached per host for 30
// minutes in localStorage and refreshed in the background, so pages paint from cache and the
ddiff --git a/packages/openvibe-shared/test/shared-modules.test.js b/packages/openvibe-shared/test/shared-modules.test.js
iindex 16dbb775..3cc2004e 100644
---- a/packages/openvibe-shared/test/shared-modules.test.js
++++ b/packages/openvibe-shared/test/shared-modules.test.js
@@@ -16,3 +16,19 @@ assert.equal(icons.resolve('yt'), 'youtube');
assert.equal(icons.resolve('<img onerror=1>'), 'ov', 'unknown names fall back to the mark');
for (const f of ['../island.js', '../ui.js']) { const m = require(f); assert.equal(typeof (m.start || m.toast), 'function', `${f} loads without a DOM`); }
console.log('shared modules: all checks passed');
++
++// The browser bundles must at least evaluate in a bare global (this caught a missing `root` once).
++{
++ const vm = require('vm'); const fs = require('fs'); const path = require('path');
++ for (const f of ['footer.js', 'navbar.js', 'island.js', 'ui.js', 'ov-icons.js', 'history.js', 'sso-client.js']) {
++ const ctx = vm.createContext({ console });
++ ctx.globalThis = ctx; ctx.window = ctx; ctx.self = ctx;
++ ctx.localStorage = { getItem: () => null, setItem() {} }; ctx.location = { hostname: 'openvibe.tools', href: 'https://openvibe.tools/' };
++ assert.doesNotThrow(() => vm.runInContext(fs.readFileSync(path.join(__dirname, '..', f), 'utf8'), ctx), `${f} evaluates`);
++ }
++ const ctx = vm.createContext({ console }); ctx.globalThis = ctx; ctx.window = ctx; ctx.location = { hostname: 'openvibe.media', href: 'https://openvibe.media/' }; ctx.localStorage = { getItem: () => null, setItem() {} };
++ vm.runInContext(fs.readFileSync(path.join(__dirname, '..', 'footer.js'), 'utf8'), ctx);
++ const html = ctx.OpenVibeFooter.buildHTML({ service: 'media', variant: 'full' });
++ assert.ok(html.includes('Legal') && html.includes('ovf-brand'), 'footer renders without chrome data');
++ console.log('browser bundles evaluate: ok');
++}