/* global describe, it, before */

const Brave = require('../lib/brave')
const {urlInput} = require('../lib/selectors')

describe('content loading', function () {
  function * setup (client) {
    yield client
      .waitForUrl(Brave.newTabUrl)
      .waitForBrowserWindow()
      .waitForVisible(urlInput)
  }

  Brave.beforeAll(this)
  before(function * () {
    yield setup(this.app.client)
  })

  it('does not allow local files to load other other files', function * () {
    var page1 = Brave.fixtureUrl('localFileAccess.html')
    yield this.app.client
      .tabByIndex(0)
      .url(page1)
      .windowByUrl(Brave.browserWindowUrl)
      .waitUntil(function () {
        return this.getText('.tabTitle').then((title) => {
          return title === 'failed'
        })
      })
  })

  it('does not support battery status API', function * () {
    var page1 = Brave.fixtureUrl('battery.html')
    yield this.app.client
      .tabByIndex(0)
      .url(page1)
      .windowByUrl(Brave.browserWindowUrl)
      .waitUntil(function () {
        return this.getText('.tabTitle').then((title) => {
          return title === 'fail'
        })
      })
  })
})

/* global describe, it, before */

const Brave = require('../lib/brave')
const {urlInput} = require('../lib/selectors')

describe('content loading', function () {
  function * setup (client) {
    yield client
      .waitForUrl(Brave.newTabUrl)
      .waitForBrowserWindow()
      .waitForVisible(urlInput)
  }

  Brave.beforeAll(this)
  before(function * () {
    yield setup(this.app.client)
  })

  it('does not allow local files to load other other files', function * () {
    var page1 = Brave.fixtureUrl('localFileAccess.html')
    yield this.app.client
      .tabByIndex(0)
      .url(page1)
      .windowByUrl(Brave.browserWindowUrl)
      .waitUntil(function () {
        return this.getText('.tabTitle').then((title) => {
          return title === 'failed'
        })
      })
  })

  it('always returns 100% for battery status API', function * () {
    var page1 = Brave.fixtureUrl('battery.html')
    yield this.app.client
      .tabByIndex(0)
      .url(page1)
      .windowByUrl(Brave.browserWindowUrl)
      .waitUntil(function () {
        return this.getText('.tabTitle').then((title) => {
          return title === '100%'
        })
      })
  })
})

update battery test for https://github.com/brave/browser-laptop/commit/0e50ff39f0daf356e1749260f13d5aadb137c5d0 auditors @bbondy