| OLD | NEW |
| 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 |assert_selection(sample, tester, expectedText)| assertion | 7 // This file provides |assert_selection(sample, tester, expectedText)| assertion |
| 8 // to W3C test harness to write editing test cases easier. | 8 // to W3C test harness to write editing test cases easier. |
| 9 // | 9 // |
| 10 // |sample| is an HTML fragment text which is inserted as |innerHTML|. It should | 10 // |sample| is an HTML fragment text which is inserted as |innerHTML|. It should |
| (...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 */ | 508 */ |
| 509 constructor(sampleText) { | 509 constructor(sampleText) { |
| 510 /** @const @type {!HTMLIFame} */ | 510 /** @const @type {!HTMLIFame} */ |
| 511 this.iframe_ = document.createElement('iframe'); | 511 this.iframe_ = document.createElement('iframe'); |
| 512 document.body.appendChild(this.iframe_); | 512 document.body.appendChild(this.iframe_); |
| 513 /** @const @type {!HTMLDocument} */ | 513 /** @const @type {!HTMLDocument} */ |
| 514 this.document_ = this.iframe_.contentDocument; | 514 this.document_ = this.iframe_.contentDocument; |
| 515 /** @const @type {!Selection} */ | 515 /** @const @type {!Selection} */ |
| 516 this.selection_ = this.iframe_.contentWindow.getSelection(); | 516 this.selection_ = this.iframe_.contentWindow.getSelection(); |
| 517 this.selection_.document = this.document_; | 517 this.selection_.document = this.document_; |
| 518 this.selection_.document.offsetLeft = this.iframe_.offsetLeft; |
| 519 this.selection_.document.offsetTop = this.iframe_.offsetTop; |
| 518 | 520 |
| 519 this.load(sampleText); | 521 this.load(sampleText); |
| 520 } | 522 } |
| 521 | 523 |
| 522 /** @return {!HTMLDocument} */ | 524 /** @return {!HTMLDocument} */ |
| 523 get document() { return this.document_; } | 525 get document() { return this.document_; } |
| 524 | 526 |
| 525 /** @return {!Selection} */ | 527 /** @return {!Selection} */ |
| 526 get selection() { return this.selection_; } | 528 get selection() { return this.selection_; } |
| 527 | 529 |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 650 // case. | 652 // case. |
| 651 if (actualText === expectedText) | 653 if (actualText === expectedText) |
| 652 sample.remove(); | 654 sample.remove(); |
| 653 assert_equals(actualText, expectedText, description); | 655 assert_equals(actualText, expectedText, description); |
| 654 } | 656 } |
| 655 | 657 |
| 656 // Export symbols | 658 // Export symbols |
| 657 window.Sample = Sample; | 659 window.Sample = Sample; |
| 658 window.assert_selection = assertSelection; | 660 window.assert_selection = assertSelection; |
| 659 })(); | 661 })(); |
| OLD | NEW |