diff options
author | Thomas Buckley-Houston <tom@tombh.co.uk> | 2018-01-28 16:13:13 +0800 |
---|---|---|
committer | Thomas Buckley-Houston <tom@tombh.co.uk> | 2018-01-30 17:50:55 +0800 |
commit | 0b3ff030cd208e53fa254e032ec230c334d71b60 (patch) | |
tree | 343489393a2f8b4d6e7cb6d3f083f29b61b53e45 | |
parent | 29857748592a601f6c96f0fa708e529959cf2441 (diff) |
Release v0.2.3v0.2.3
-rw-r--r-- | .travis.yml | 33 | ||||
-rw-r--r-- | Dockerfile | 5 | ||||
-rwxr-xr-x | contrib/release_if_new_version.sh | 30 | ||||
-rw-r--r-- | interfacer/.goreleaser.yml | 4 | ||||
-rwxr-xr-x | interfacer/contrib/setup_browsh.sh | 4 | ||||
-rwxr-xr-x | interfacer/contrib/setup_firefox.sh | 14 | ||||
-rwxr-xr-x | interfacer/contrib/setup_go.sh | 16 | ||||
-rwxr-xr-x | interfacer/contrib/upx_compress_binary.sh | 6 | ||||
-rw-r--r-- | interfacer/main.go | 51 | ||||
-rwxr-xr-x | webext/contrib/setup_node.sh | 13 | ||||
-rw-r--r-- | webext/dist/manifest.json | 2 | ||||
-rw-r--r-- | webext/manifest.json | 2 | ||||
-rw-r--r-- | webext/src/background/boot.js | 41 | ||||
-rw-r--r-- | webext/src/background/hub_mixin.js | 4 | ||||
-rw-r--r-- | webext/src/background/tab_commands_mixin.js | 1 | ||||
-rw-r--r-- | webext/src/background/tty_commands_mixin.js | 1 | ||||
-rw-r--r-- | webext/src/dom/frame_builder.js | 67 | ||||
-rw-r--r-- | webext/test/integration/helper.js | 12 | ||||
-rw-r--r-- | webext/test/mocha.opts | 2 |
19 files changed, 210 insertions, 98 deletions
diff --git a/.travis.yml b/.travis.yml index b9eff91..1bd5ef5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,21 @@ if: tag IS blank # Don't trigger builds if -language: node_js +language: go +go: + - 1.9.x + +addons: + # Use the full version number with ".0" if needed. This value is scraped + # by setup scripts. + firefox: "58.0" + apt: + packages: + - rpm + - bsdtar + - upx-ucl + env: global: - - GOPATH=$HOME/gopath - - PATH=$PATH:/$HOME/bin:$GOPATH/bin - - REPO_ROOT=$GOPATH/src + - REPO_ROOT=$GOPATH/src/browsh - MDN_USER="user:13243312:78" # MDN_TOKEN - secure: "sKZ1/oBLKNWA0v16d4Yg8V500zIwZwEUpcnW7SMRpeqJMbzlR7GKLpJ/VX6ZAYexokBEEbU+JnI3/aHOmJaO9h2/+b1qwrQqje6totC6/rPhxkdxGxI9jETzPdL0V0XErK4rK2URATEANRnJUFLVuFGaXh6dUZDrbtn8NxDSfZEQGmHlqex5TcqPxmK2v0Lb3l2FcVF2kxGYpKMmjKFQbGBHdjFN5qOrS3jmkHjC6Ie8CaM9ezy55e3sOIrNr/u4kWJAOGE2cT3rjqcmPYaCRRzkiy7q3sYEI6jC9vfOZeyFI6E0e3VPDv+OGq+lnUBbgVjGhiG9LxIJ9Z3JEY9z5OspeczpLiQT2rhstqwDolyhx2liiI9cZe0d+uiLo2YyYKe1RELlClB6cQi9p/J8vJpyVEutIoq8Sdv13vbnJMAmPQi1OD9qtOgBR9cngy5yWIPyizgpcAr6kCYxztwIX4y1wrlHPUdTApDnfJNkNOSBwYBTigmlFZf8BkGXB4JOhcQ8KZM3H2OdOP2rANZIOd1ficgyHgKNt4iomIC/i5d7qnV6OZfzirQgx7yzWqjwoGrPg+OvL9MeY9dMltGsfFL80FLudIzN8sqj3BUYioXWX8GCyVML/XoMPbLpcSLBRMxskUhNSYbaTQ2qML7H5Kv/wce71BXMknzyT0s/mNs=" @@ -12,27 +23,21 @@ env: - secure: "boYctu4EQI2og3YWpD54yo1LzibgBNrYN3exbfwxaNNbJuQscprAlOOG5Y1O7MBgzG9AP1DeON3X0al7g/IYMrsMsrSGhJLq9w2/ntwMiUIyKfTAP8rB5fASRSYxA5mqhpjXK4iIzqG2xiOr1SmCbpT9ew0AXP/HgxQprsppBbH+H4HyrP4cejIbfk8ajU/XvrDmhOY4s/IZIy+vfEfZH5xheJnG3iWFICwWUF5CIjjr6fQpq9ZbL2sDMvzruYPMAQ3iDfBrUr+ZhN4PPjrzvCRUNpoUoPsXCsFDPMcZpBjSHH5ZELPRBzHSdJignIjHaV0UtLtFApZl49lzq749r2Sno2ba4JCd0RIgMERjNluXynkJiHrL2tMR8HYhOmoeLMdX0zrguv+136+Jn04gQde3S+FI1/sN0/Xa14xD7SGMUT1MgFnwKgFXOFeUd3VpvbpFg6RWVgpCnaDd2/AKL+mQDEgL4yRg9q95a6Q5ub/c6nla8/E4asEvYGlJPj0OG/MKvJMi0gnKuP4+nil0jgGeKki3k1UxwvldlS+n7HUhQ7c4B9c61KS19i+z5SxBiXjilL+zGlAVVgRcalIoKQrTRDSRKnKZkR5Ant0CLjt44pncHLwlYXD/aPuLNihCa4AqUlpYPYru0pQawXNkVnk6E/cg2DAsp7oDcpcg540=" before_install: - - ./interfacer/contrib/setup_firefox.sh - ./interfacer/contrib/setup_go.sh - - cp -rfp $TRAVIS_BUILD_DIR -T $REPO_ROOT + - ./webext/contrib/setup_node.sh + - mkdir -p $REPO_ROOT && cp -rfp $TRAVIS_BUILD_DIR -T $REPO_ROOT install: - cd $REPO_ROOT/interfacer - dep ensure - cd $REPO_ROOT/webext + - source ~/.nvm/nvm.sh - npm run get-gobindata - npm install - npm run build script: - npm test -after_failure: - cat $REPO_ROOT/interfacer/debug.log - cat $REPO_ROOT/interfacer/spec.log after_success: - - BROWSH_ENV=RELEASE npm run build - - rvm install 2.5.0 - - gem install --no-ri --no-rdoc fpm - - apt-get install rpm - - go get github.com/goreleaser/goreleaser - - cd $REPO_ROOT/interfacer - - goreleaser + - $REPO_ROOT/contrib/release_if_new_version.sh @@ -4,11 +4,14 @@ RUN useradd user RUN su user WORKDIR /home/user ADD ./interfacer/contrib/setup_firefox.sh . +ADD .travis.yml . RUN ./setup_firefox.sh -RUN rm ./setup_firefox.sh +RUN rm ./setup_firefox.sh && rm .travis.yml ENV PATH="/home/user/firefox:${PATH}" +ADD ./webpack/manifest.json . ADD ./interfacer/contrib/setup_browsh.sh . RUN ./setup_browsh.sh +RUN rm ./setup_browsh.sh && rm manifest.json CMD ["/home/user/browsh"] diff --git a/contrib/release_if_new_version.sh b/contrib/release_if_new_version.sh index eece72a..9e27ae8 100755 --- a/contrib/release_if_new_version.sh +++ b/contrib/release_if_new_version.sh @@ -7,15 +7,27 @@ manifest=$PROJECT_ROOT/webext/manifest.json line=$(cat $manifest | grep '"version"') manifest_version=$(echo $line | grep -o '".*"' | cut -d " " -f 2 | sed 's/"//g') -latest_tagged_version=$(git tag --list 'v*.*.*' | head -n1 | sed -e "s/^v//") - -if [[ "$manifest_version" != "$latest_tagged_version" ]]; then - cd $PROJECT_ROOT/interfacer - goreleaser - git config --global user.email "builds@travis-ci.com" - git config --global user.name "Travis CI" - # `/dev/null` needed to prevent Github token appearing in logs - git push --tags --quiet https://$GITHUB_TOKEN@github.com/tombh/texttop > /dev/null 2>&1 +latest_tagged_version=$(git tag --sort=v:refname --list 'v*.*.*' | tail -n1 | sed -e "s/^v//") + +if [[ "$manifest_version" == "$latest_tagged_version" ]]; then + echo "Not running release as there's no new version." + exit 0 fi +git reset --hard +git tag v$manifest_version + +cd $PROJECT_ROOT/webext +#BROWSH_ENV=RELEASE npm run build + +cd $PROJECT_ROOT/interfacer +rvm install 2.5.0 +gem install --no-ri --no-rdoc fpm +go get -u github.com/goreleaser/goreleaser +goreleaser +git config --global user.email "builds@travis-ci.com" +git config --global user.name "Travis CI" +# `/dev/null` needed to prevent Github token appearing in logs +git push --tags --quiet https://$GITHUB_TOKEN@github.com/tombh/texttop > /dev/null 2>&1 + diff --git a/interfacer/.goreleaser.yml b/interfacer/.goreleaser.yml index 7131540..311c823 100644 --- a/interfacer/.goreleaser.yml +++ b/interfacer/.goreleaser.yml @@ -28,3 +28,7 @@ fpm: dependencies: - firefox + +release: + # Obviously need to remove this when we release properly. Hopefully very soon! + prerelease: true diff --git a/interfacer/contrib/setup_browsh.sh b/interfacer/contrib/setup_browsh.sh index 966471f..ba21b26 100755 --- a/interfacer/contrib/setup_browsh.sh +++ b/interfacer/contrib/setup_browsh.sh @@ -18,8 +18,8 @@ fi line=$(cat $manifest | grep '"version"') version=$(echo $line | grep -o '".*"' | cut -d " " -f 2 | sed 's/"//g') -base='https://github.com/browsh-org/browsh/releases/download' -release_url="$base/browsh-$version/browsh-linux-amd64-$version" +base='https://github.com/tombh/texttop/releases/download' +release_url="$base/v$version/browsh_${version}_linux_amd64" curl -L -o browsh $release_url chmod a+x browsh diff --git a/interfacer/contrib/setup_firefox.sh b/interfacer/contrib/setup_firefox.sh index 5a9b826..44fb144 100755 --- a/interfacer/contrib/setup_firefox.sh +++ b/interfacer/contrib/setup_firefox.sh @@ -1,11 +1,21 @@ #!/bin/bash -FIREFOX_VERSION=58.0b16 +set -ex + +PROJECT_ROOT=$(git rev-parse --show-toplevel) +line=$(cat $PROJECT_ROOT/.travis.yml | grep 'firefox: "') +version=$(echo $line | grep -o '".*"' | cut -d " " -f 1 | sed 's/"//g') + +# Firefox is needed both for testing in Travis and embedding in the Docker +# image used by the Browsh as a Service platform. So we need to be able to +# give a specific and consistent version pin. +FIREFOX_VERSION=$version mkdir -p $HOME/bin pushd $HOME/bin curl -L -o firefox.tar.bz2 https://ftp.mozilla.org/pub/firefox/releases/$FIREFOX_VERSION/linux-x86_64/en-US/firefox-$FIREFOX_VERSION.tar.bz2 -apt-get -y install bzip2 bzip2 -d firefox.tar.bz2 tar xf firefox.tar popd + +firefox --version diff --git a/interfacer/contrib/setup_go.sh b/interfacer/contrib/setup_go.sh index 382d43e..a546083 100755 --- a/interfacer/contrib/setup_go.sh +++ b/interfacer/contrib/setup_go.sh @@ -1,23 +1,9 @@ #!/bin/bash set -e -GOLANG_VERSION=1.9.3 +# Install `dep` the current defacto dependency for Golang GOLANG_DEP_VERSION=0.3.2 - -export GOPATH=$HOME/gopath -export PATH=$PATH:/$HOME/bin:$GOPATH/bin dep_url=https://github.com/golang/dep/releases/download/v$GOLANG_DEP_VERSION/dep-linux-amd64 -golang_archive=go$GOLANG_VERSION.linux-amd64.tar.gz -golang_url=https://dl.google.com/go/$golang_archive - -mkdir -p $HOME/bin -mkdir -p $GOPATH/bin - -# Install Golang -curl -L -o $golang_archive $golang_url -tar -C $HOME/bin -xzf $golang_archive - -# Install `dep` the current defacto dependency for Golang curl -L -o $GOPATH/bin/dep $dep_url chmod +x $GOPATH/bin/dep diff --git a/interfacer/contrib/upx_compress_binary.sh b/interfacer/contrib/upx_compress_binary.sh index 1555d82..f29bf60 100755 --- a/interfacer/contrib/upx_compress_binary.sh +++ b/interfacer/contrib/upx_compress_binary.sh @@ -2,9 +2,5 @@ set -ex pushd dist -curl -sL -o upx.txz https://github.com/upx/upx/releases/download/v3.94/upx-3.94-amd64_linux.tar.xz -tar -xvf upx.txz -cp upx-3.94-amd64_linux/upx . -rm -rf upx-3.94-amd64_linux -./upx */* +upx */* popd diff --git a/interfacer/main.go b/interfacer/main.go index 107d42c..30d55d5 100644 --- a/interfacer/main.go +++ b/interfacer/main.go @@ -15,7 +15,7 @@ import ( "time" // Termbox seems to be one of the best projects in any language for handling terminal input. - // It's cross-platform and the maintainer is disciplined about supporting the baseline of escape + // It"s cross-platform and the maintainer is disciplined about supporting the baseline of escape // codes that work across the majority of terminals. "github.com/nsf/termbox-go" @@ -27,7 +27,7 @@ var ( webSocketAddresss = flag.String("port", ":3334", "Web socket service address") firefoxBinary = flag.String("firefox", "firefox", "Path to Firefox executable") isFFGui = flag.Bool("with-gui", false, "Don't use headless Firefox") - isUseExistingFirefox = flag.Bool("use-existing-ff", false, "Whether Browsh shouls launch Firefox or not") + isUseExistingFirefox = flag.Bool("use-existing-ff", false, "Whether Browsh should launch Firefox or not") useFFProfile = flag.String("ff-profile", "default", "Firefox profile to use") upgrader = websocket.Upgrader{ CheckOrigin: func(r *http.Request) bool { return true }, @@ -37,6 +37,39 @@ var ( stdinChannel = make(chan string) marionette net.Conn ffCommandCount = 0 + defaultFFPrefs = map[string]string{ + "browser.startup.homepage": "'about:blank'", + "startup.homepage_welcome_url": "'about:blank'", + "startup.homepage_welcome_url.additional": "''", + "devtools.errorconsole.enabled": "true", + "devtools.chrome.enabled": "true", + + // Send Browser Console (different from Devtools console) output to + // STDOUT. + "browser.dom.window.dump.enabled": "true", + + // From: + // http://hg.mozilla.org/mozilla-central/file/1dd81c324ac7/build/automation.py.in//l388 + // Make url-classifier updates so rare that they won"t affect tests. + "urlclassifier.updateinterval": "172800", + // Point the url-classifier to a nonexistent local URL for fast failures. + "browser.safebrowsing.provider.0.gethashURL": + "'http://localhost/safebrowsing-dummy/gethash'", + "browser.safebrowsing.provider.0.keyURL": + "'http://localhost/safebrowsing-dummy/newkey'", + "browser.safebrowsing.provider.0.updateURL": + "'http://localhost/safebrowsing-dummy/update'", + + // Disable self repair/SHIELD + "browser.selfsupport.url": "'https://localhost/selfrepair'", + // Disable Reader Mode UI tour + "browser.reader.detectedFirstArticle": "true", + + // Set the policy firstURL to an empty string to prevent + // the privacy info page to be opened on every "web-ext run". + // (See #1114 for rationale) + "datareporting.policy.firstRunURL": "''", + } ) func setupLogging() { @@ -185,6 +218,7 @@ func webSocketWriter(ws *websocket.Conn) { } shutdown(err.Error()) } + log(fmt.Sprintf("TTY sent: %s", message)) } } @@ -274,7 +308,7 @@ func setFFPreference(key string, value string) { sendFirefoxCommand("setContext", map[string]interface{}{"value": "content"}) } -// Consume output from Marionette, we don't do anything with it. It's just +// Consume output from Marionette, we don't do anything with it. It"s just // useful to have it in the logs. func readMarionette() { buffer := make([]byte, 4096) @@ -304,14 +338,18 @@ func loadHomePage() { sendFirefoxCommand("get", args) } +func setDefaultPreferences() { + for key, value := range defaultFFPrefs { + setFFPreference(key, value) + } +} + func setupFirefox() { go startHeadlessFirefox() // TODO: Do something better than just waiting time.Sleep(3 * time.Second) firefoxMarionette() - // Send Browser Console (different from Devtools console) output to - // STDOUT. - setFFPreference("browser.dom.window.dump.enabled", "true") + setDefaultPreferences() installWebextension() go loadHomePage() } @@ -319,6 +357,7 @@ func setupFirefox() { func main() { initialise() if !*isUseExistingFirefox { + println("Starting Browsh...") setupFirefox() } else { println("Waiting for a Firefox instance to connect...") diff --git a/webext/contrib/setup_node.sh b/webext/contrib/setup_node.sh index c303cf1..c825f48 100755 --- a/webext/contrib/setup_node.sh +++ b/webext/contrib/setup_node.sh @@ -1,8 +1,11 @@ #!/bin/bash -# See `/.nvmrc` for current Node version -NVM_VERSION=0.33.8 -curl -o- https://raw.githubusercontent.com/creationix/nvm/v$NVM_VERSION/install.sh | bash -source $HOME/.nvm/nvm.sh -nvm install +if ! type "nvm" > /dev/null; then + rm -rf ~/.nvm + NVM_VERSION=0.33.8 + curl -o- https://raw.githubusercontent.com/creationix/nvm/v$NVM_VERSION/install.sh | bash + source $HOME/.nvm/nvm.sh +fi + +nvm install # See `/.nvmrc` for current Node version diff --git a/webext/dist/manifest.json b/webext/dist/manifest.json index 57444a7..d17920f 100644 --- a/webext/dist/manifest.json +++ b/webext/dist/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "Browsh", - "version": "0.2.2", + "version": "0.2.3", "description": "Renders the browser as realtime, interactive, TTY-compatible text", diff --git a/webext/manifest.json b/webext/manifest.json index 57444a7..d17920f 100644 --- a/webext/manifest.json +++ b/webext/manifest.json @@ -1,7 +1,7 @@ { "manifest_version": 2, "name": "Browsh", - "version": "0.2.2", + "version": "0.2.3", "description": "Renders the browser as realtime, interactive, TTY-compatible text", diff --git a/webext/src/background/boot.js b/webext/src/background/boot.js index 9d0381e..1051307 100644 --- a/webext/src/background/boot.js +++ b/webext/src/background/boot.js @@ -21,17 +21,18 @@ export default class extends mixins(HubMixin, TTYCommandsMixin, TabCommandsMixin this.terminal = new WebSocket('ws://localhost:3334'); this.terminal.addEventListener('open', (_event) => { this.log("Webextension connected to the terminal's websocket server"); + this._listenForTerminalMessages(); this._connectToBrowser(); }); - this._listenForTerminalMessages(); } // Mostly listening for forwarded STDIN from the terminal. Therefore, the user // pressing the arrow keys, typing, moving the mouse, etc, etc. But we also listen // to TTY resize events too. _listenForTerminalMessages() { + this.log('Starting to listen to TTY') this.terminal.addEventListener('message', (event) => { - this.log('Message from terminal', event.data); + this.log('Message from terminal: ' + event.data); this.handleTerminalMessage(event.data) }); } @@ -52,11 +53,37 @@ export default class extends mixins(HubMixin, TTYCommandsMixin, TabCommandsMixin browser.runtime.onMessage.addListener(this._newTabHandler.bind(this)); } + getTabsOnSuccess(windowInfoArray) { + for (let windowInfo of windowInfoArray) { + this.log(`BACKGROUND: Window: ${windowInfo.id}`); + this.log('BACKGROUND: Current tab count: ' + windowInfo.tabs.length); + windowInfo.tabs.map((tab) => { + this.log(tab.title + ' - ' + tab.url) + }); + } + } + + getTabsOnError(error) { + this.log(`Error: ${error}`); + } + + countTabs() { + var getting = browser.windows.getAll({ + populate: true, + windowTypes: ["normal"] + }); + getting.then(this.getTabsOnSuccess.bind(this), this.getTabsOnError.bind(this)); + } + _newTabHandler(_request, sender, sendResponse) { + //this.countTabs() this.log(`Tab ${sender.tab.id} registered with background process`); // Send the tab back to itself, such that it can be enlightened unto its own nature + this.log('BACKGROUND: bouncing tab info back to tab: ' + sender.tab) sendResponse(sender.tab); - if (sender.tab.active) this.active_tab_id = sender.tab.id; + this.log('BACKGROUND: is tab active? ' + sender.tab.active) + //if (sender.tab.active) this.active_tab_id = sender.tab.id; + this.active_tab_id = sender.tab.id; } // This is the main communication channel for all back and forth messages to tabs @@ -78,7 +105,6 @@ export default class extends mixins(HubMixin, TTYCommandsMixin, TabCommandsMixin } _focussedTabHandler(tab) { - this.log(tab); this.active_tab_id = tab.id } @@ -98,14 +124,21 @@ export default class extends mixins(HubMixin, TTYCommandsMixin, TabCommandsMixin // heartbeat in the background process that switches automatically to the current active // tab. _startFrameRequestLoop() { + let frame_count = 0; + this.log('BACKGROUND: frame loop starting') setInterval(() => { + frame_count += 1; + if (frame_count < 10) this.log('BACKGROUND: frame loop called') if (!this.tty_width || !this.tty_height) { this.log("Not sending frame to TTY without TTY size") return; } + if (frame_count < 10) this.log('BACKGROUND: considering widnow resize') if (this._is_intial_window_pending) this._initialWindowResize(); if (!this.tabs.hasOwnProperty(this.active_tab_id)) return; + if (frame_count < 10) this.log('BACKGROUND: there is an active tab, requesting frame') this.sendToCurrentTab('/request_frame'); + if (frame_count < 10) this.log('BACKGROUND: frame requested') }, 1000); } } diff --git a/webext/src/background/hub_mixin.js b/webext/src/background/hub_mixin.js index d475a6b..5328019 100644 --- a/webext/src/background/hub_mixin.js +++ b/webext/src/background/hub_mixin.js @@ -1,3 +1,5 @@ +import stripAnsi from 'strip-ansi'; + // Here we keep the public funcntions used to mediate communications between // the background process, tabs and the terminal. export default (Base) => class extends Base { @@ -11,6 +13,8 @@ export default (Base) => class extends Base { log(...message) { if (message.length === 1) message = message[0]; + message = stripAnsi(message); + message = message.replace(/\u001b\[/g, 'ESC'); this.sendToTerminal(message); } diff --git a/webext/src/background/tab_commands_mixin.js b/webext/src/background/tab_commands_mixin.js index 279cbb6..698b365 100644 --- a/webext/src/background/tab_commands_mixin.js +++ b/webext/src/background/tab_commands_mixin.js @@ -12,6 +12,7 @@ export default (MixinBase) => class extends MixinBase { case '/frame': this._current_frame = JSON.parse(message.slice(7)); this._applyUI(); + this.log(this._current_frame.join('')); this._sendCurrentFrame(); break; case '/tab_info': diff --git a/webext/src/background/tty_commands_mixin.js b/webext/src/background/tty_commands_mixin.js index 6136dbb..3e3c460 100644 --- a/webext/src/background/tty_commands_mixin.js +++ b/webext/src/background/tty_commands_mixin.js @@ -15,7 +15,6 @@ export default (MixinBase) => class extends MixinBase { case '/tty_size': this.tty_width = parts[1]; this.tty_height = parts[2]; - if(this.active_tab_id) this.sendTTYSizeToBrowser(); if (this.char_width && this.char_height){ this.resizeBrowserWindow(); } diff --git a/webext/src/dom/frame_builder.js b/webext/src/dom/frame_builder.js index b71413b..dfab965 100644 --- a/webext/src/dom/frame_builder.js +++ b/webext/src/dom/frame_builder.js @@ -20,14 +20,21 @@ export default class FrameBuilder extends BaseBuilder{ } sendFrame() { + this._log('FRAME_BUILDER: sending frame...') this._setupDimensions(); + this._log('FRAME_BUILDER: dimensions setup...') this._compileFrame(); + this._log('FRAME_BUILDER: frame compiled...') this._buildFrame(); + this._log('FRAME_BUILDER: frame built...') this._sendTabInfo(); + this._log('FRAME_BUILDER: sent tab info...') if (!this._is_first_frame_finished) { this._sendMessage('/status,parsing_complete'); } + this._log(this.frame) this._sendMessage(`/frame,${JSON.stringify(this.frame)}`); + this._log('FRAME_BUILDER: frame sent to background...') this._is_first_frame_finished = true; } @@ -38,6 +45,9 @@ export default class FrameBuilder extends BaseBuilder{ window.addEventListener("unload", () => { this._sendMessage('/status,window_unload') }); + window.addEventListener('error', (event) => { + this._log("TAB JS: " + event) + }); // Whilst developing this webextension the auto reload only reloads this code, // not the page, so we don't get the `DOMContentLoaded` event to kick everything off. if (this._isWindowAlreadyLoaded()) this._init(100); @@ -94,35 +104,36 @@ export default class FrameBuilder extends BaseBuilder{ } _handleBackgroundMessage(message) { + this._log('FRAME_BUILDER: received message from BG: ' + message) let input, url; - const parts = message.split(','); - const command = parts[0]; - switch (command) { - case '/request_frame': - this.sendFrame(); - break; - case '/tty_size': - this.tty_width = parseInt(parts[1]); - this.tty_height = parseInt(parts[2]); - this._log(`Tab received TTY size: ${this.tty_width}x${this.tty_height}`); - break; - case '/stdin': - input = JSON.parse(utils.rebuildArgsToSingleArg(parts)); - this._handleUserInput(input); - break; - case '/url': - url = utils.rebuildArgsToSingleArg(parts); - document.location.href = url; - break; - case '/location_back': - history.go(-1); - break; - case '/window_stop': - window.stop(); - break; - default: - this._log('Unknown command sent to tab', message); - } + const parts = message.split(','); + const command = parts[0]; + switch (command) { + case '/request_frame': + this.sendFrame(); + break; + case '/tty_size': + this.tty_width = parseInt(parts[1]); + this.tty_height = parseInt(parts[2]); + this._log(`Tab received TTY size: ${this.tty_width}x${this.tty_height}`); + break; + case '/stdin': + input = JSON.parse(utils.rebuildArgsToSingleArg(parts)); + this._handleUserInput(input); + break; + case '/url': + url = utils.rebuildArgsToSingleArg(parts); + document.location.href = url; + break; + case '/location_back': + history.go(-1); + break; + case '/window_stop': + window.stop(); + break; + default: + this._log('Unknown command sent to tab', message); + } } _handleUserInput(input) { diff --git a/webext/test/integration/helper.js b/webext/test/integration/helper.js index 15e3e86..610efa3 100644 --- a/webext/test/integration/helper.js +++ b/webext/test/integration/helper.js @@ -56,11 +56,11 @@ class Helper { broadcastOutput() { let buffer = ''; this.browshPTY.on('data', (data) => { + this.log('BROWSH CLI: ' + this.cleanFrame(data)); if (this.is_last_startup_message_consumed) { buffer += data; buffer = this.broadcastBrowserOutput(buffer); } else { - this.log(data); this.frame = this.cleanFrame(data); } }); @@ -73,6 +73,7 @@ class Helper { if (buffer.includes(cursor_reset_sig)) { buffer = this.cleanFrame(buffer); this.frame = this.insertTTYLines(buffer); + this.log(this.frame); buffer = ''; } return buffer; @@ -146,18 +147,23 @@ class Helper { // then may as well keep consistent. startFirefox() { const dir = this.project_root + '/webext/dist'; - this.firefoxPTY = pty.spawn('bash', [], { + // Curiously, suing `bash` on Travis causes $PATH to overwritten and this + // PTY to not be able to find `node`. + this.firefoxPTY = pty.spawn('sh', [], { env: process.env }); this.firefoxPTY.write(`cd ${dir} \r`); let command = `../node_modules/.bin/web-ext run ` + `--firefox="${this.project_root}/webext/contrib/firefoxheadless.sh" ` + `--verbose ` + + `--no-reload ` + `--url https://google.com ` + `\r`; this.firefoxPTY.write(command); this.firefoxPTY.on('data', (data) => { - this.log(data); + const ignore = /gconf|x11|dbus/i.test(data); + if (ignore) return; + this.log('WEBEXT RUNNER: ' + data); }); } } diff --git a/webext/test/mocha.opts b/webext/test/mocha.opts index d6b26ce..c9b9611 100644 --- a/webext/test/mocha.opts +++ b/webext/test/mocha.opts @@ -1,2 +1,2 @@ --require babel-register ---timeout 15000 +--timeout 60000 |