| 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 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 document.body.appendChild(this.iframe_); | 547 document.body.appendChild(this.iframe_); |
| 548 /** @const @type {!HTMLDocument} */ | 548 /** @const @type {!HTMLDocument} */ |
| 549 this.document_ = this.iframe_.contentDocument; | 549 this.document_ = this.iframe_.contentDocument; |
| 550 /** @const @type {!Selection} */ | 550 /** @const @type {!Selection} */ |
| 551 this.selection_ = this.iframe_.contentWindow.getSelection(); | 551 this.selection_ = this.iframe_.contentWindow.getSelection(); |
| 552 this.selection_.document = this.document_; | 552 this.selection_.document = this.document_; |
| 553 this.selection_.document.offsetLeft = this.iframe_.offsetLeft; | 553 this.selection_.document.offsetLeft = this.iframe_.offsetLeft; |
| 554 this.selection_.document.offsetTop = this.iframe_.offsetTop; | 554 this.selection_.document.offsetTop = this.iframe_.offsetTop; |
| 555 this.selection_.setClipboardData = setClipboardData; | 555 this.selection_.setClipboardData = setClipboardData; |
| 556 | 556 |
| 557 // Set focus to sample IFRAME to make |eventSender| and |
| 558 // |testRunner.execCommand()| to work on sample rather than main frame. |
| 559 this.iframe_.focus(); |
| 557 this.load(sampleText); | 560 this.load(sampleText); |
| 558 } | 561 } |
| 559 | 562 |
| 560 /** @return {!HTMLDocument} */ | 563 /** @return {!HTMLDocument} */ |
| 561 get document() { return this.document_; } | 564 get document() { return this.document_; } |
| 562 | 565 |
| 563 /** @return {!Selection} */ | 566 /** @return {!Selection} */ |
| 564 get selection() { return this.selection_; } | 567 get selection() { return this.selection_; } |
| 565 | 568 |
| 566 /** | 569 /** |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 707 throw new Error(`${description}\n` + | 710 throw new Error(`${description}\n` + |
| 708 `\t expected ${expectedText},\n` + | 711 `\t expected ${expectedText},\n` + |
| 709 `\t but got ${actualText},\n` + | 712 `\t but got ${actualText},\n` + |
| 710 `\t sameupto ${commonPrefixOf(expectedText, actualText)}`); | 713 `\t sameupto ${commonPrefixOf(expectedText, actualText)}`); |
| 711 } | 714 } |
| 712 | 715 |
| 713 // Export symbols | 716 // Export symbols |
| 714 window.Sample = Sample; | 717 window.Sample = Sample; |
| 715 window.assert_selection = assertSelection; | 718 window.assert_selection = assertSelection; |
| 716 })(); | 719 })(); |
| OLD | NEW |