Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(119)

Side by Side Diff: third_party/WebKit/LayoutTests/editing/spelling/spellcheck_test.js

Issue 2734013002: Implement cold mode invocation for idle time spell checker (Closed)
Patch Set: rebased Mar 7 Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 'use strict'; 5 'use strict';
6 6
7 // This file provides 7 // This file provides
8 // |spellcheck_test(sample, tester, expectedText, opt_title)| asynchronous test 8 // |spellcheck_test(sample, tester, expectedText, opt_title)| asynchronous test
9 // to W3C test harness for easier writing of spellchecker test cases. 9 // to W3C test harness for easier writing of spellchecker test cases.
10 // 10 //
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 return internals.lastSpellCheckRequestSequence(document) !== 283 return internals.lastSpellCheckRequestSequence(document) !==
284 internals.lastSpellCheckProcessedSequence(document); 284 internals.lastSpellCheckProcessedSequence(document);
285 } 285 }
286 286
287 /** @type {string} */ 287 /** @type {string} */
288 const kTitle = 'title'; 288 const kTitle = 'title';
289 /** @type {string} */ 289 /** @type {string} */
290 const kCallback = 'callback'; 290 const kCallback = 'callback';
291 /** @type {string} */ 291 /** @type {string} */
292 const kIsSpellcheckTest = 'isSpellcheckTest'; 292 const kIsSpellcheckTest = 'isSpellcheckTest';
293 /** @type {string} */
294 const kNeedsFullCheck = 'needsFullCheck';
293 295
294 // Spellchecker gets triggered not only by text and selection change, but also 296 // Spellchecker gets triggered not only by text and selection change, but also
295 // by focus change. For example, misspelling markers in <INPUT> disappear when 297 // by focus change. For example, misspelling markers in <INPUT> disappear when
296 // the window loses focus, even though the selection does not change. 298 // the window loses focus, even though the selection does not change.
297 // Therefore, we disallow spellcheck tests from running simultaneously to 299 // Therefore, we disallow spellcheck tests from running simultaneously to
298 // prevent interference among them. If we call spellcheck_test while another 300 // prevent interference among them. If we call spellcheck_test while another
299 // test is running, the new test will be added into testQueue waiting for the 301 // test is running, the new test will be added into testQueue waiting for the
300 // completion of the previous test. 302 // completion of the previous test.
301 303
302 /** @type {boolean} */ 304 /** @type {boolean} */
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 /** @type {!MarkerSerializer} */ 352 /** @type {!MarkerSerializer} */
351 const serializer = new MarkerSerializer({ 353 const serializer = new MarkerSerializer({
352 spelling: '#', 354 spelling: '#',
353 grammar: '~'}); 355 grammar: '~'});
354 356
355 assert_equals(serializer.serialize(sample.document), expectedText); 357 assert_equals(serializer.serialize(sample.document), expectedText);
356 testObject.done(); 358 testObject.done();
357 }); 359 });
358 }; 360 };
359 361
360 if (internals.idleTimeSpellCheckerState !== undefined && 362 if (internals.idleTimeSpellCheckerState !== undefined) {
361 internals.idleTimeSpellCheckerState(sample.document) === 'HotModeRequest ed') { 363 if (internals.idleTimeSpellCheckerState(sample.document) === 'HotModeReque sted')
362 internals.runIdleTimeSpellChecker(sample.document); 364 internals.runIdleTimeSpellChecker(sample.document);
365 if (testObject.properties[kNeedsFullCheck]) {
366 while (internals.idleTimeSpellCheckerState(sample.document) !== 'Inactiv e')
367 internals.runIdleTimeSpellChecker(sample.document);
368 }
363 } 369 }
364 370
365 // For a test that does not create new spell check request, a synchronous 371 // For a test that does not create new spell check request, a synchronous
366 // verification finishes everything. 372 // verification finishes everything.
367 verificationForCurrentTest(); 373 verificationForCurrentTest();
368 }); 374 });
369 } 375 }
370 376
371 add_result_callback(testObj => { 377 add_result_callback(testObj => {
372 if (!testObj.properties[kIsSpellcheckTest]) 378 if (!testObj.properties[kIsSpellcheckTest])
(...skipping 27 matching lines...) Expand all
400 next.tester, next.expectedText); 406 next.tester, next.expectedText);
401 }); 407 });
402 408
403 /** 409 /**
404 * @param {Object=} passedArgs 410 * @param {Object=} passedArgs
405 * @return {!Object} 411 * @return {!Object}
406 */ 412 */
407 function getTestArguments(passedArgs) { 413 function getTestArguments(passedArgs) {
408 const args = {}; 414 const args = {};
409 args[kIsSpellcheckTest] = true; 415 args[kIsSpellcheckTest] = true;
410 [kTitle, kCallback].forEach(key => args[key] = undefined); 416 [kTitle, kCallback, kNeedsFullCheck].forEach(key => args[key] = undefined);
411 if (!passedArgs) 417 if (!passedArgs)
412 return args; 418 return args;
413 419
414 if (typeof(passedArgs) === 'string') { 420 if (typeof(passedArgs) === 'string') {
415 args[kTitle] = passedArgs; 421 args[kTitle] = passedArgs;
416 return args; 422 return args;
417 } 423 }
418 424
419 [kTitle, kCallback].forEach(key => args[key] = passedArgs[key]); 425 [kTitle, kCallback, kNeedsFullCheck].forEach(
426 key => args[key] = passedArgs[key]);
420 return args; 427 return args;
421 } 428 }
422 429
423 /** 430 /**
424 * @param {!Sample|string} input 431 * @param {!Sample|string} input
425 * @param {function(!Document)|string} tester 432 * @param {function(!Document)|string} tester
426 * @param {string} expectedText 433 * @param {string} expectedText
427 * @param {Object=} opt_args 434 * @param {Object=} opt_args
428 */ 435 */
429 function spellcheckTest(input, tester, expectedText, opt_args) { 436 function spellcheckTest(input, tester, expectedText, opt_args) {
(...skipping 16 matching lines...) Expand all
446 window.testRunner.setMockSpellCheckerEnabled(true); 453 window.testRunner.setMockSpellCheckerEnabled(true);
447 window.testRunner.setSpellCheckResolvedCallback(() => { 454 window.testRunner.setSpellCheckResolvedCallback(() => {
448 if (verificationForCurrentTest) 455 if (verificationForCurrentTest)
449 verificationForCurrentTest(); 456 verificationForCurrentTest();
450 }); 457 });
451 } 458 }
452 459
453 // Export symbols 460 // Export symbols
454 window.spellcheck_test = spellcheckTest; 461 window.spellcheck_test = spellcheckTest;
455 })(); 462 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698