├── .gitignore ├── index.js ├── test ├── fixtures │ └── index.html └── test.js ├── package.json └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | 3 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const serve = require('serve'); 3 | 4 | const server = serve(path.join(__dirname, 'test/fixtures'), { 5 | port: 8123, 6 | ignore: ['node_modules'] 7 | }); -------------------------------------------------------------------------------- /test/fixtures/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |
7 |
8 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "crypto-getrandombytes", 3 | "version": "0.0.1", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "start": "node index.js", 8 | "test-file": "ACCESS=file node test/test.js", 9 | "test-remote": "ACCESS=remote node test/test.js" 10 | }, 11 | "author": "Shane Tomlinson (https://shanetomlinson.com)", 12 | "license": "MPL-2.0", 13 | "dependencies": { 14 | "selenium-webdriver": "^3.5.0", 15 | "serve": "^6.2.0" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /test/test.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | const path = require('path'); 3 | 4 | const accessMethod = process.env.ACCESS || 'remote'; 5 | const quitWhenComplete = process.env.QUIT !== 'false'; 6 | 7 | const { Builder, By, until } = require('selenium-webdriver'); 8 | 9 | const driver = new Builder() 10 | .forBrowser('firefox') 11 | .usingServer('http://localhost:4444/') 12 | .build(); 13 | 14 | 15 | if (accessMethod === 'remote') { 16 | // Fetching from the remote fails. 17 | driver.get('http://127.0.0.1:8123'); 18 | } else if (accessMethod === 'file') { 19 | // Fetching from the file passes. 20 | driver.get(`file:///${path.join(__dirname, 'fixtures/index.html')}`); 21 | } 22 | 23 | driver.wait(until.elementLocated(By.id('numbers')), 1000) 24 | .then(null, (err) => { 25 | console.log('uh oh', String(err)); 26 | }) 27 | .then(() => { 28 | if (quitWhenComplete) { 29 | driver.quit(); 30 | } 31 | }); 32 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Reduced test case for crypto.getRandomBytes error 2 | 3 | When Firefox 56+ is run with geckodriver, invoking crypto.getRandomBytes fails with: 4 | 5 | > OperationError: The operation failed for an operation-specific reason 6 | 7 | It only fails when run over an http or https connection, opening the file directly using `file:///` does not fail. 8 | 9 | ## Prerequisites 10 | * Node 0.8.x 11 | * Firefox 56.0 or 57.0b5 12 | 13 | ## Installation 14 | 15 | 1. git clone https://github.com/shane-tomlinson/crypto-getRandomBytes-failure-case.git 16 | 2. cd crypto-getRandomBytes-failure-case 17 | 3. npm install 18 | 19 | ## Running the test 20 | 21 | Running the test requires 3 processes to be run: 22 | 23 | 1. geckodriver - I tested against 0.17, 0.18, and 0.19 24 | 2. the web server with the test case 25 | 3. the test runner. 26 | 27 | The process I used: 28 | 1. In window 1, start geckodriver. 29 | 2. In window 2, go to the project directory and run `npm start` to start the HTTP server. 30 | 3. In window 3, go to the project directory and run `npm run test-remote` 31 | 32 | Watch the geckodriver logs, they will say: 33 | 34 | > OperationError: The operation failed for an operation-specific reason 35 | 36 | To keep the browser open after the test fails, run the test with the `QUIT=false` environment variable: 37 | 38 | > QUIT=false npm run test-remote 39 | 40 | ## Watching the test pass - open the file directly. 41 | 42 | In step 3 above, run `npm run test-file` --------------------------------------------------------------------------------