| 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 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 } | 502 } |
| 503 | 503 |
| 504 class Sample { | 504 class Sample { |
| 505 /** | 505 /** |
| 506 * @public | 506 * @public |
| 507 * @param {string} sampleText | 507 * @param {string} sampleText |
| 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 if (!document.body) |
| 513 document.body = document.createElement("body"); |
| 512 document.body.appendChild(this.iframe_); | 514 document.body.appendChild(this.iframe_); |
| 513 /** @const @type {!HTMLDocument} */ | 515 /** @const @type {!HTMLDocument} */ |
| 514 this.document_ = this.iframe_.contentDocument; | 516 this.document_ = this.iframe_.contentDocument; |
| 515 /** @const @type {!Selection} */ | 517 /** @const @type {!Selection} */ |
| 516 this.selection_ = this.iframe_.contentWindow.getSelection(); | 518 this.selection_ = this.iframe_.contentWindow.getSelection(); |
| 517 this.selection_.document = this.document_; | 519 this.selection_.document = this.document_; |
| 518 this.selection_.document.offsetLeft = this.iframe_.offsetLeft; | 520 this.selection_.document.offsetLeft = this.iframe_.offsetLeft; |
| 519 this.selection_.document.offsetTop = this.iframe_.offsetTop; | 521 this.selection_.document.offsetTop = this.iframe_.offsetTop; |
| 520 | 522 |
| 521 this.load(sampleText); | 523 this.load(sampleText); |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 // case. | 654 // case. |
| 653 if (actualText === expectedText) | 655 if (actualText === expectedText) |
| 654 sample.remove(); | 656 sample.remove(); |
| 655 assert_equals(actualText, expectedText, description); | 657 assert_equals(actualText, expectedText, description); |
| 656 } | 658 } |
| 657 | 659 |
| 658 // Export symbols | 660 // Export symbols |
| 659 window.Sample = Sample; | 661 window.Sample = Sample; |
| 660 window.assert_selection = assertSelection; | 662 window.assert_selection = assertSelection; |
| 661 })(); | 663 })(); |
| OLD | NEW |