diff --git a/configure.ac b/configure.ac index eebe661c5..724643cd7 100644 --- a/configure.ac +++ b/configure.ac @@ -1194,6 +1194,7 @@ if test "$enable_androidapp" = "yes"; then fi AC_CONFIG_FILES([test/run_unit.sh],[chmod +x test/run_unit.sh]) +AC_CONFIG_FILES([coolstress],[chmod +x coolstress]) AC_OUTPUT diff --git a/coolstress.in b/coolstress.in new file mode 100755 index 000000000..1fc323196 --- /dev/null +++ b/coolstress.in @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +# This is a wrapper - please edit coolstress.in + +prefix="@prefix@" +datadir="@datadir@" +datarootdir="@datarootdir@" +pkgdatadir="$(datadir)/@PACKAGE@" + +# to allow runnning when not installed +abs_top_builddir="@abs_top_builddir@" +abs_top_srcdir="@abs_top_srcdir@" + +node --inspect $abs_top_srcdir/loleaflet/test/load.js "$abs_top_srcdir" "$abs_top_builddir" $* diff --git a/loleaflet/Makefile.am b/loleaflet/Makefile.am index b7c438bcd..ae993b652 100644 --- a/loleaflet/Makefile.am +++ b/loleaflet/Makefile.am @@ -684,10 +684,3 @@ $(abs_srcdir)/admin/jsconfig.json: \"exclude\" : [\"node_modules\"]\n}" > $@ jsconfig: $(abs_srcdir)/jsconfig.json $(abs_srcdir)/admin/jsconfig.json - -load-test: $(LOLEAFLET_JS) - @(cd test ; node ./load.js \ - $(abspath $(srcdir)/js/global.js) \ - $(abspath $(NODE_MODULES_JS_SRC)) \ - $(abspath $(LOLEAFLET_LIBS_JS_SRC)) \ - $(abspath $(LOLEAFLET_JS))) diff --git a/loleaflet/js/global.js b/loleaflet/js/global.js index 0ef024f83..e9a030dd2 100644 --- a/loleaflet/js/global.js +++ b/loleaflet/js/global.js @@ -170,7 +170,7 @@ if (global.mode.isChromebook()) return false; - if (L.Browser.mobile && L.Browser.cypressTest) { + if (global.L.Browser.mobile && L.Browser.cypressTest) { return true; } diff --git a/loleaflet/package.json b/loleaflet/package.json index 5a944c145..85bc41d01 100644 --- a/loleaflet/package.json +++ b/loleaflet/package.json @@ -39,6 +39,7 @@ ], "license": "BSD-2-Clause", "dependencies": { + "canvas": "^2.6.1", "jsdom": "^16.4.0" } } diff --git a/loleaflet/test/load.js b/loleaflet/test/load.js index 7fca25405..38b115bbf 100644 --- a/loleaflet/test/load.js +++ b/loleaflet/test/load.js @@ -1,55 +1,82 @@ -console.log('Startup') - var vm = require("vm"); var fs = require("fs"); -// stubs -/*navigator = { - userAgent: 'loadtest', - vendor: 'collabora', - platform: 'Linux' -}; */ +var top_srcdir = process.argv[2]; +var top_builddir = process.argv[3]; + +var to_load = top_srcdir + '/test/data/hello-world.ods'; +if (process.argv.length > 4) { + to_load = process.argv[4] +} // jsdom for browser emulation const jsdom = require('jsdom'); const { JSDOM } = jsdom; -window = new JSDOM(`...`).window; -window.host = 'localhost'; -window.location = 'https://localhost:9980'; -// cf. loleaflet.hml - Window properties: -window.host = ''; -window.serviceRoot = ''; -window.versionPath = '6.4.3'; -window.accessToken = ''; -window.accessTokenTTL = ''; -window.accessHeader = ''; -window.loleafletLogging = 'true'; -window.enableWelcomeMessage = false; -window.enableWelcomeMessageButton = false; -window.outOfFocusTimeoutSecs = 1000000; -window.idleTimeoutSecs = 1000000; -window.reuseCookies = ''; -window.protocolDebug = false; -window.frameAncestors = ''; -window.socketProxy = false; -window.tileSize = 256; -window.uiDefaults = {}; +var data = fs.readFileSync(top_builddir + '/loleaflet/dist/loleaflet.html', {encoding: 'utf8'}); -// stub the DOM left and right: +data = data.replace(/%SERVICE_ROOT%\/loleaflet\/%VERSION%/g, top_builddir + '/loleaflet/dist'); +data = data.replace(/%SERVICE_ROOT%/g, ''); +data = data.replace(/%VERSION%/g, 'dist'); +data = data.replace(/%HOST%/g, 'wss://localhost:9980'); +data = data.replace(/%ACCESS_TOKEN%/g, ''); +data = data.replace(/%ACCESS_TOKEN_TTL%/g, '0'); +data = data.replace(/%ACCESS_HEADER%/g, ''); +data = data.replace(/%LOLEAFLET_LOGGING%/g, 'true'); +data = data.replace(/%ENABLE_WELCOME_MSG%/g, 'false'); +data = data.replace(/%ENABLE_WELCOME_MSG%/g, 'false'); +data = data.replace(/%ENABLE_WELCOME_MSG_BTN%/g, 'false'); +data = data.replace(/%USER_INTERFACE_MODE%/g, ''); +data = data.replace(/%OUT_OF_FOCUS_TIMEOUT_SECS%/g, '1000000'); +data = data.replace(/%IDLE_TIMEOUT_SECS%/g, '1000000'); +data = data.replace(/%REUSE_COOKIES%/g, 'false'); +data = data.replace(/%PROTOCOL_DEBUG%/g, 'true'); +data = data.replace(/%FRAME_ANCESTORS%/g, ''); +data = data.replace(/%SOCKET_PROXY%/g, 'false'); +data = data.replace(/%UI_DEFAULTS%/g, '{}'); -context = vm.createContext(window, {name: 'simulation' }) +window = new JSDOM(data, + { runScripts: 'dangerously', + pretendToBeVisual: true, + includeNodeLocations: true, + url: 'file:///tmp/notthere/loleaflet.html?file_path=file:///' + to_load, + resources: 'usable', + beforeParse(window) { + console.debug('Before script parsing'); + }, + done(errors, window) { + console.debug('Errors ' + errors); + } + }).window; -L = { Browser: {} }; +// Make it possible to mock sizing properties +Object.defineProperty(window.HTMLElement.prototype, "clientWidth", { + get: function() { + return this.___clientWidth || 0; + } +}); +Object.defineProperty(window.HTMLElement.prototype, "clientHeight", { + get: function() { + return this.___clientHeight || 0; + } +}); -for (var i = 2; i < process.argv.length; ++i) -{ - console.log('load "' + process.argv[i] + '"'); +console.log('Finished bootstrapping: ' + window.L.Browser.mobile + ' desktop ' + window.mode.isDesktop() + ' now running'); +console.debug('Window size ' + window.innerWidth + 'x' + window.innerHeight); - var data = fs.readFileSync(process.argv[i]); - const script = new vm.Script(data); - script.runInContext(context); -} +window.HTMLElement.prototype.getBoundingClientRect = function() { + console.debug('getBoundingClientRect for ' + this.id); + return { + width: 0, height: 0, top: 0, left: 0 + }; +}; +window.onload = function() { + console.debug('socket ' + window.socket); + map = window.socket._map; -console.log('Bootstrapped mobile: ' + L.Browser.mobile + ' desktop ' + window.mode.isDesktop()); + console.debug('Initialize / size map pieces ' + map); + // Force some sizes onto key pieces: + map._container.___clientWidth = 1024; + map._container.___clientHeight = 768; +};