<commit_before>import time
import os
import subprocess
import sys
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from nw_util import *

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

def click_and_assert(driver, id, expect):
    driver.find_element_by_id(id).click()
    wait_window_handles(driver, 2)
    print 'switch to opened window'
    driver.switch_to_window(driver.window_handles[-1])
    driver.find_element_by_id('getwinsize').click()
    result = driver.find_element_by_id('result').get_attribute('innerHTML')
    print 'window size: %s' % result
    assert (expect in result)
    driver.close()
    wait_window_handles(driver, 1)
    driver.switch_to_window(driver.window_handles[0])

chrome_options = Options()
chrome_options.add_argument("nwapp=" + os.path.dirname(os.path.abspath(__file__)))

driver = webdriver.Chrome(executable_path=os.environ['CHROMEDRIVER'], chrome_options=chrome_options, service_log_path="log", service_args=["--verbose"])
time.sleep(1)
try:
    print driver.current_url
    driver.implicitly_wait(10)
    print 'open new window with `window.open()`'
    click_and_assert(driver, 'winopen', '400,300')
    print 'open new window by `window.open()` with width and height'
    print 'newly opended window should have size of 320,350'
    click_and_assert(driver, 'winopenwithsize', '320,350')
    print 'open new window with <a target="_blank">'
    click_and_assert(driver, 'linkopen', '400,300')
    print 'bind new-win-policy and newly opened window should have size of 388,300'
    driver.find_element_by_id('bindnewwinpolicy').click()
    print 'open new window with `window.open()` after new-win-policy'
    click_and_assert(driver, 'winopen', '388,300')
    print 'open new window with <a target="_blank"> after new-win-policy'
    click_and_assert(driver, 'linkopen', '388,300')
finally:
    driver.quit()<commit_msg>[test] issue4221-win-open-manifest: workaround 1px issue on buildslave<commit_after>import time
import os
import subprocess
import sys
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from nw_util import *

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

def click_and_assert(driver, id, exp_w, exp_h):
    driver.find_element_by_id(id).click()
    wait_window_handles(driver, 2)
    print 'switch to opened window'
    driver.switch_to_window(driver.window_handles[-1])
    driver.find_element_by_id('getwinsize').click()
    result = driver.find_element_by_id('result').get_attribute('innerHTML')
    print 'window size: %s' % result
    expect = str(exp_w) + ',' + str(exp_h)
    expect2 = str(exp_w + 1) + ',' + str(exp_h + 1)
    assert (expect in result or expect2 in result)
    driver.close()
    wait_window_handles(driver, 1)
    driver.switch_to_window(driver.window_handles[0])

chrome_options = Options()
chrome_options.add_argument("nwapp=" + os.path.dirname(os.path.abspath(__file__)))

driver = webdriver.Chrome(executable_path=os.environ['CHROMEDRIVER'], chrome_options=chrome_options, service_log_path="log", service_args=["--verbose"])
time.sleep(1)
try:
    print driver.current_url
    driver.implicitly_wait(10)
    print 'open new window with `window.open()`'
    click_and_assert(driver, 'winopen', 400, 300)
    print 'open new window by `window.open()` with width and height'
    print 'newly opended window should have size of 320,350'
    click_and_assert(driver, 'winopenwithsize', 320, 350)
    print 'open new window with <a target="_blank">'
    click_and_assert(driver, 'linkopen', 400, 300)
    print 'bind new-win-policy and newly opened window should have size of 388,300'
    driver.find_element_by_id('bindnewwinpolicy').click()
    print 'open new window with `window.open()` after new-win-policy'
    click_and_assert(driver, 'winopen', 388, 300)
    print 'open new window with <a target="_blank"> after new-win-policy'
    click_and_assert(driver, 'linkopen', 388, 300)
finally:
    driver.quit()
{'fraction_non_alphanumeric': 0.12270699058006941, 'fraction_numerical': 0.026524541398116015, 'mean_word_length': 5.132218844984802, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '7479707', 'n_tokens_mistral': 1410, 'n_tokens_neox': 1309, 'n_words': 307}