<commit_before>/* global describe, it, before */

const Brave = require('../lib/brave')
const messages = require('../../js/constants/messages')
const settings = require('../../js/constants/settings')
const {urlInput} = require('../lib/selectors')

describe('tabs', function () {
  function * setup (client) {
    yield client
      .waitUntilWindowLoaded()
      .waitForVisible('#window')
      .waitForVisible(urlInput)
  }

  describe('new tab signal', function () {
    Brave.beforeAll(this)
    before(function *() {
      yield setup(this.app.client)
    })

    it('creates a new tab when signaled', function *() {
      yield this.app.client
        .ipcSend(messages.SHORTCUT_NEW_FRAME)
        .waitForExist('.tab[data-frame-key="2"]')
    })

    it('makes the non partitioned webview visible', function *() {
      yield this.app.client
        .waitForVisible('webview:not([partition])')
    })
  })

  describe('new private tab signal', function () {
    Brave.beforeAll(this)
    before(function *() {
      yield setup(this.app.client)
    })
    it('creates a new private tab when signaled', function *() {
      yield this.app.client
        .ipcSend(messages.SHORTCUT_NEW_FRAME, 'http://www.brave.com', { isPrivate: true })
        .waitForExist('.tab.private[data-frame-key="2"]')
    })
    it('makes the private webview visible', function *() {
      yield this.app.client
        .waitForVisible('webview[partition="private-1"]')
    })
  })

  describe('new session tab signal', function () {
    Brave.beforeAll(this)
    before(function *() {
      yield setup(this.app.client)
    })
    it('creates a new session tab when signaled', function *() {
      yield this.app.client
        .ipcSend(messages.SHORTCUT_NEW_FRAME, 'http://www.brave.com', { isPartitioned: true })
        .waitForExist('.tab[data-frame-key="2"]')
    })
    it('makes the new session webview visible', function *() {
      yield this.app.client
        .waitForVisible('webview[partition="persist:partition-1"]')
    })
  })

  describe('close tab', function() {
    Brave.beforeAll(this)
    before(function *() {
      yield setup(this.app.client)
    })
    it('should close the tab', function *() {
      yield this.app.client
        .ipcSend(messages.SHORTCUT_NEW_FRAME, 'https://www.brave.com')
        .waitForExist('.tab[data-frame-key="2"]')
        .ipcSend(messages.SHORTCUT_CLOSE_FRAME)

      yield this.app.client
        .isExisting('.tab[data-frame-key="2"]').should.eventually.be.false
    })
    it('should undo last closed tab', function *() {
      yield this.app.client
        .ipcSend(messages.SHORTCUT_NEW_FRAME, 'https://www.brave.com')
        .waitForExist('.tab[data-frame-key="3"]')
        .ipcSend(messages.SHORTCUT_CLOSE_FRAME)

      yield this.app.client
        .ipcSend(messages.SHORTCUT_UNDO_CLOSED_FRAME)
        .waitForExist('.tab[data-frame-key="3"]').should.eventually.be.true
    })
  })

  describe('webview background-tab events', function () {
    Brave.beforeAll(this)
    before(function *() {
      yield setup(this.app.client)
    })
    it('opens background tab', function *() {
      yield this.app.client
        .sendWebviewEvent(1, 'new-window', {}, 'new-window', 'http://www.brave.com', 'some-frame', 'background-tab')
    })
    it('opens in a new active tab', function *() {
      yield this.app.client.waitForExist('.frameWrapper:not(.isActive) webview[data-frame-key="2"]')
    })<commit_msg>Cleaned up tabTest<commit_after>/* global describe, it, before */

const Brave = require('../lib/brave')
const messages = require('../../js/constants/messages')
const settings = require('../../js/constants/settings')
const {urlInput} = require('../lib/selectors')

describe('tabs', function () {
  function * setup (client) {
    yield client
      .waitUntilWindowLoaded()
      .waitForVisible('#window')
      .waitForVisible(urlInput)
  }

  describe('new tab signal', function () {
    Brave.beforeAll(this)
    before(function *() {
      yield setup(this.app.client)
    })

    it('creates a new tab when signaled', function *() {
      yield this.app.client
        .ipcSend(messages.SHORTCUT_NEW_FRAME)
        .waitForExist('.tab[data-frame-key="2"]')
    })

    it('makes the non partitioned webview visible', function *() {
      yield this.app.client
        .waitForVisible('webview:not([partition])')
    })
  })

  describe('new private tab signal', function () {
    Brave.beforeAll(this)
    before(function *() {
      yield setup(this.app.client)
    })
    it('creates a new private tab when signaled', function *() {
      yield this.app.client
        .ipcSend(messages.SHORTCUT_NEW_FRAME, 'http://www.brave.com', { isPrivate: true })
        .waitForExist('.tab.private[data-frame-key="2"]')
    })
    it('makes the private webview visible', function *() {
      yield this.app.client
        .waitForVisible('webview[partition="private-1"]')
    })
  })

  describe('new session tab signal', function () {
    Brave.beforeAll(this)
    before(function *() {
      yield setup(this.app.client)
    })
    it('creates a new session tab when signaled', function *() {
      yield this.app.client
        .ipcSend(messages.SHORTCUT_NEW_FRAME, 'http://www.brave.com', { isPartitioned: true })
        .waitForExist('.tab[data-frame-key="2"]')
    })
    it('makes the new session webview visible', function *() {
      yield this.app.client
        .waitForVisible('webview[partition="persist:partition-1"]')
    })
  })

  describe('close tab', function() {
    var windowCountBeforeTabClose = 3
    var windowCountAfterTabClose = 2
    Brave.beforeAll(this)
    before(function *() {
      yield setup(this.app.client)
    })
    it('should close the tab', function *() {
      yield this.app.client
        .ipcSend(messages.SHORTCUT_NEW_FRAME)
        .waitUntil(function() {
          return this.getWindowCount().then(count => count === windowCountBeforeTabClose)
        })
        .ipcSend(messages.SHORTCUT_CLOSE_FRAME)
        .waitUntil(function() {
          return this.getWindowCount().then(count => count === windowCountAfterTabClose)
        })
       })
    it('should undo last closed tab', function *() {
      yield this.app.client
        .ipcSend(messages.SHORTCUT_NEW_FRAME)
        .waitForExist('.tab[data-frame-key="3"]')
        .ipcSend(messages.SHORTCUT_CLOSE_FRAME)
        .waitUntil(function() {
          return this.getWindowCount().then(count => count === windowCountAfterTabClose)
        })
        .ipcSend(messages.SHORTCUT_UNDO_CLOSED_FRAME)
        .waitForExist('.tab[data-frame-key="3"]')
        .waitUntil(function() {
          return this.getWindowCount().then(count => count === windowCountBeforeTabClose)
        })
    })
  })

  describe('webview background-tab events', function () {
    Brave.beforeAll(this)
    before(function *() {
      yield setup(this.app.client)
    })
    it('opens background tab', function *() {
      yield this.app.client
        .sendWebviewEvent(1, 'new-window', {}, 'new-window', 'http://www.brave.com', 'some-frame', 'background-tab')
    })
    it('opens in a new active tab', function *() {
      yield this.app.client.waitForExist('.frameWrapper:not(.isActive) webview[data-frame-key="2"]')
    })
{'fraction_non_alphanumeric': 0.15941629955947137, 'fraction_numerical': 0.0030286343612334803, 'mean_word_length': 2.9398047722342735, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 8, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4709061', 'n_tokens_mistral': 2312, 'n_tokens_neox': 2281, 'n_words': 400}