2018-03-20 03:00:12 +00:00
|
|
|
/**
|
|
|
|
* Copyright 2017 Google Inc. All rights reserved.
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
const path = require('path');
|
|
|
|
|
2018-08-09 23:51:12 +00:00
|
|
|
module.exports.addTests = function({testRunner, expect}) {
|
2018-03-20 03:00:12 +00:00
|
|
|
const {describe, xdescribe, fdescribe} = testRunner;
|
2019-02-06 06:32:41 +00:00
|
|
|
const {it, fit, xit, it_fails_ffox} = testRunner;
|
2018-03-20 03:00:12 +00:00
|
|
|
const {beforeAll, beforeEach, afterAll, afterEach} = testRunner;
|
|
|
|
describe('input', function() {
|
2019-02-23 01:22:46 +00:00
|
|
|
it('should upload the file', async({page, server}) => {
|
2018-03-20 03:00:12 +00:00
|
|
|
await page.goto(server.PREFIX + '/input/fileupload.html');
|
|
|
|
const filePath = path.relative(process.cwd(), __dirname + '/assets/file-to-upload.txt');
|
|
|
|
const input = await page.$('input');
|
|
|
|
await input.uploadFile(filePath);
|
|
|
|
expect(await page.evaluate(e => e.files[0].name, input)).toBe('file-to-upload.txt');
|
|
|
|
expect(await page.evaluate(e => {
|
|
|
|
const reader = new FileReader();
|
|
|
|
const promise = new Promise(fulfill => reader.onload = fulfill);
|
|
|
|
reader.readAsText(e.files[0]);
|
|
|
|
return promise.then(() => reader.result);
|
|
|
|
}, input)).toBe('contents of the file');
|
|
|
|
});
|
2019-02-06 06:32:41 +00:00
|
|
|
it_fails_ffox('keyboard.modifiers()', async({page, server}) => {
|
2018-03-20 03:00:12 +00:00
|
|
|
const keyboard = page.keyboard;
|
|
|
|
expect(keyboard._modifiers).toBe(0);
|
|
|
|
await keyboard.down('Shift');
|
|
|
|
expect(keyboard._modifiers).toBe(8);
|
|
|
|
await keyboard.down('Alt');
|
|
|
|
expect(keyboard._modifiers).toBe(9);
|
|
|
|
await keyboard.up('Shift');
|
|
|
|
await keyboard.up('Alt');
|
|
|
|
expect(keyboard._modifiers).toBe(0);
|
|
|
|
});
|
|
|
|
});
|
2018-04-09 23:38:00 +00:00
|
|
|
};
|