Skip to content

Commit

Permalink
[CI] Remove "window." prefix in layout tests for test_shell injected …
Browse files Browse the repository at this point in the history
…global names

This doesn't include those in 'if' statements.

Bug: 703768
TBR: already agreed in blink-dev; too many files.
Cq-Include-Trybots: master.tryserver.chromium.linux:linux_layout_tests_layout_ng
Change-Id: I499b91695e177d2a498d96cf20537ee146e22d06
Reviewed-on: https://chromium-review.googlesource.com/1057947
Reviewed-by: Xianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#558467}
  • Loading branch information
wangxianzhu committed May 14, 2018
1 parent 4c0b8a1 commit af4fa41
Show file tree
Hide file tree
Showing 1,399 changed files with 2,904 additions and 2,894 deletions.
42 changes: 26 additions & 16 deletions docs/testing/writing_layout_tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,15 +228,24 @@ implemented in
and
[content/shell/test_runner/test_runner.cc](../../content/shell/test_runner/test_runner.cc).
By skimming the `TestRunnerBindings::Install` method, we learn that the
testRunner API is presented by the `window.testRunner` and
`window.layoutTestsController` objects, which are synonyms. Reading the
testRunner API is presented by the `.testRunner` etc. objects. Reading the
`TestRunnerBindings::GetObjectTemplateBuilder` method tells us what properties
are available on the `window.testRunner` object.
are available on the `testRunner` object.

*** aside
`window.testRunner` is the preferred way to access the `testRunner` APIs.
`window.layoutTestsController` is still supported because it is used by
3rd-party tests.
Another popular Blink-specific API 'internals' defined in
[third_party/blink/renderer/core/testing/internals.idl](../../third_party/blink/renderer/core/testing/internals.idl)
contains more direct access to blink internals.

*** note
If possible, a test using blink-specific testing APIs should be written not to
depend on the APIs, so that it can also work directly in a browser. If the test
does need the APIs to work, it should still check if the API is available before
using the API. Note that though we omit the `window.` prefix when using the
APIs, we should use the qualified name in the `if` statement:
```javascript
if (window.testRunner)
testRunner.waitUntilDone();
```
***

*** note
Expand All @@ -250,7 +259,7 @@ and uses the `testRunner` API.

See the [content/shell/test_runner/](../../content/shell/test_runner/) directory and
[WebKit's LayoutTests guide](https://trac.webkit.org/wiki/Writing%20Layout%20Tests%20for%20DumpRenderTree)
for other useful APIs. For example, `window.eventSender`
for other useful APIs. For example, `eventSender`
([content/shell/test_runner/event_sender.h](../../content/shell/test_runner/event_sender.h)
and
[content/shell/test_runner/event_sender.cc](../../content/shell/test_runner/event_sender.cc))
Expand Down Expand Up @@ -415,8 +424,8 @@ being discussed on

## Pixel Tests

`testRunner` APIs such as `window.testRunner.dumpAsTextWithPixelResults()` and
`window.testRunner.dumpDragImage()` create an image result that is associated
`testRunner` APIs such as `testRunner.dumpAsTextWithPixelResults()` and
`testRunner.dumpDragImage()` create an image result that is associated
with the test. The image result is compared against an image baseline, which is
an `-expected.png` file associated with the test, and the test passes if the
image result is identical to the baseline, according to a pixel-by-pixel
Expand Down Expand Up @@ -444,7 +453,7 @@ TODO: Document how to opt out of generating a layout tree when generating
pixel results.

*** promo
When using `window.testRunner.dumpAsTextWithPixelResults()`, the image result
When using `testRunner.dumpAsTextWithPixelResults()`, the image result
will always be 800x600px, because test pages are rendered in an 800x600px
viewport. Pixel tests that do not specifically cover scrolling should fit in an
800x600px viewport without creating scrollbars.
Expand Down Expand Up @@ -475,11 +484,12 @@ to use a relative path to
### Tests that need to paint, raster, or draw a frame of intermediate output

A layout test does not actually draw frames of output until the test exits.
Tests that need to generate a painted frame can use
`window.testRunner.displayAsyncThen`, which will run the machinery to put up a
frame, then call the passed callback. There is also a library at
`fast/repaint/resources/text-based-repaint.js` to help with writing paint
invalidation and repaint tests.
Tests that need to generate a painted frame can use `runAfterLayoutAndPaint()`
defined in [third_party/WebKit/LayoutTests/resources/run-after-layout-and-paint.js](../../third_party/WebKit/LayoutTests/resources/run-after-layout-and-paint.js)
which will run the machinery to put up a frame, then call the passed callback.
There is also a library at
[third_party/WebKit/LayoutTests/paint/invalidation/resources/text-based-repaint.js](../../third_party/WebKit/LayoutTests/paint/invalidation/resources/text-based-repaint.js)
to help with writing paint invalidation and repaint tests.

## Layout tree tests

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
description("This test makes sure that AccessibilityNodeObjects are properly detached when the node they point to is deleted.");

if (window.testRunner && window.accessibilityController) {
window.testRunner.dumpAsText();
testRunner.dumpAsText();

// Create an ordinary button on the page, focus it and get its accessibility role.
var button = document.createElement('button');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
description("This test makes sure that AccessibilityNodeObjects are properly detached when the node they point to is reparented to a location that allows them to have a renderer.");

if (window.testRunner && window.accessibilityController) {
window.testRunner.dumpAsText();
testRunner.dumpAsText();

// Create an ordinary button on the page, focus it and get its accessibility role.
var button = document.createElement('button');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
description("This test makes sure that AccessibilityObjects are detached when the node they point to is detached.");

if (window.testRunner && window.accessibilityController) {
window.testRunner.dumpAsText();
testRunner.dumpAsText();

// Create a button on the page, focus it and get its accessibility role.
var button = document.createElement('button');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
description("This test makes sure that a generic focusable div can get accessibility focus and gets its accessible text from contents..");

if (window.testRunner && window.accessibilityController) {
window.testRunner.dumpAsText();
testRunner.dumpAsText();

var button = document.getElementById('cake');
button.focus();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
description("This test makes sure that AccessibilityNodeObjects are created for elements in a canvas subtree.");

if (window.testRunner && window.accessibilityController) {
window.testRunner.dumpAsText();
testRunner.dumpAsText();

function appendFocusableDescendants(axObject, axFocusableList) {
for (var i = 0; i < axObject.childrenCount; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
description("This test makes sure that a canvas with and without fallback content each has the right role and description.")

if (window.testRunner && window.accessibilityController) {
window.testRunner.dumpAsText();
testRunner.dumpAsText();

document.getElementById('container').focus();
var axContainer = accessibilityController.focusedElement;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ <h5 id="heading2" tabindex="0">Heading</h5>
description("This tests a number of different elements in canvas fallback content to make sure their accessible attributes are essentially identical to the corresponding elements outside of canvas fallback content.");

if (window.testRunner && window.accessibilityController) {
window.testRunner.dumpAsText();
testRunner.dumpAsText();

function check(id1, id2) {
debug(id1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
description("This tests that labels and elements with labels in canvas fallback content have the same accessibility properties as those same elements outside of a canvas.");

if (window.testRunner && window.accessibilityController) {
window.testRunner.dumpAsText();
testRunner.dumpAsText();

window.collapseWhitespace = function(str) {
return str.replace(/\s+/g, ' ').replace(/^\s+|\s+$/g, '');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
description("This test makes sure that focusable elements in canvas fallback content are accessible.");

if (window.testRunner && window.accessibilityController) {
window.testRunner.dumpAsText();
testRunner.dumpAsText();

function check(id, expectedRole) {
debug(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
description("This test makes sure that a generic focusable div can get accessibility focus.");

if (window.testRunner && window.accessibilityController) {
window.testRunner.dumpAsText();
testRunner.dumpAsText();

document.getElementById('container').focus();
var axContainer = accessibilityController.focusedElement;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ <h5 id="heading" tabindex="0">Heading</h5>
description("This tests the clickable property of various elements, and tests that a role of an anchor element changes to link when it has a click listener.");

if (window.testRunner && window.accessibilityController) {
window.testRunner.dumpAsText();
testRunner.dumpAsText();

function isAXElementClickable(id) {
return accessibilityController.accessibleElementById(id).isClickable;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
description("This test makes sure that disabled form controls are not exposed as focusable.");

if (window.testRunner && window.accessibilityController) {
window.testRunner.dumpAsText();
testRunner.dumpAsText();

function checkControl(id) {
window.element = document.getElementById(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
testRunner.dumpAsText();

if (window.accessibilityController) {
window.axButton1 = window.accessibilityController.accessibleElementById("button1");
window.axContainer = window.accessibilityController.accessibleElementById("container");
window.axButton2 = window.accessibilityController.accessibleElementById("button2");
window.axButton1 = accessibilityController.accessibleElementById("button1");
window.axContainer = accessibilityController.accessibleElementById("container");
window.axButton2 = accessibilityController.accessibleElementById("button2");
}

var canvas = document.getElementById("canvas").getContext("2d");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
description("This test make sure that focusable elements are mapped implicitly to AX roles.");

if (window.testRunner && window.accessibilityController) {
window.testRunner.dumpAsText();
testRunner.dumpAsText();

function hasRole(id, expectedRole) {
debug(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
description("This tests that when AXPress is used DOMActivate will be handled by the input file type.")

if (window.testRunner && window.accessibilityController) {
window.testRunner.waitUntilDone();
testRunner.waitUntilDone();

var inputFile = document.getElementById("filetype");

inputFile.addEventListener("DOMActivate", function() {
debug("DOMActivate was called");
window.testRunner.notifyDone();
testRunner.notifyDone();
});

accessibilityController.accessibleElementById("filetype").press();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
description("This test makes sure that a generic focusable div can get accessibility focus and gets its accessible text from contents..");

if (window.testRunner && window.accessibilityController) {
window.testRunner.dumpAsText();
testRunner.dumpAsText();

var link = document.getElementById('link');
link.focus();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
description("This tests that ARIA attributes can be used to override the value of an input type=range even if it doesn't have an ARIA role of slider, because it has an *implicit* ARIA role of slider already. http://www.w3.org/TR/html-aapi/#el-78");

if (window.accessibilityController) {
window.axRange1 = window.accessibilityController.accessibleElementById("range1");
window.axRange2 = window.accessibilityController.accessibleElementById("range2");
window.axRange3 = window.accessibilityController.accessibleElementById("range3");
window.axRange1 = accessibilityController.accessibleElementById("range1");
window.axRange2 = accessibilityController.accessibleElementById("range2");
window.axRange3 = accessibilityController.accessibleElementById("range3");

shouldBe("axRange1.minValue", "1");
shouldBe("axRange1.maxValue", "10");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
window.jsTestIsAsync = true;

if (window.testRunner && window.accessibilityController) {
window.testRunner.dumpAsText();
testRunner.dumpAsText();

var menulist = document.getElementById("menulist");
menulist.selectedIndex = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
window.jsTestIsAsync = true;

if (window.testRunner && window.accessibilityController) {
window.testRunner.dumpAsText();
testRunner.dumpAsText();

var menulist = document.getElementById("menulist");
menulist.selectedIndex = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
description("This tests that meter element attributes min, max, value are exposed to accessibility module");

if (window.accessibilityController) {
window.axMeter1 = window.accessibilityController.accessibleElementById("meter1");
window.axMeter1 = accessibilityController.accessibleElementById("meter1");

shouldBe("axMeter1.minValue", "0");
shouldBe("axMeter1.maxValue", "10");
Expand Down
2 changes: 1 addition & 1 deletion third_party/WebKit/LayoutTests/accessibility/readonly.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ <h5 id="heading1" tabindex="0">Heading</h5>
description("This tests which elements expose themselves as readonly. Readonly here refers to whether the item is not editable, not whether a control value can be changed vs if it's unavailable.");

if (window.testRunner && window.accessibilityController) {
window.testRunner.dumpAsText();
testRunner.dumpAsText();

function check(id, expected_readonly) {
debug(id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
description("This tests that a spin button supports range value attributes.")

if (window.testRunner && window.accessibilityController) {
window.testRunner.dumpAsText();
testRunner.dumpAsText();

function endsWith(str, suffix) {
str = '' + str;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
}

if (window.testRunner && window.accessibilityController) {
window.testRunner.dumpAsText();
testRunner.dumpAsText();

var container = accessibilityController.accessibleElementById("svgroot");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<script src="resources/animation-test-helpers.js" type="text/javascript"></script>
<script type="text/javascript" charset="utf-8">
if (window.testRunner) {
window.testRunner.dumpAsTextWithPixelResults();
testRunner.dumpAsTextWithPixelResults();
}

const expectedValues = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
setTimeout(fireNewMockLevel, 0);
}, batteryStatusFailure);

window.testRunner.setPageVisibility("hidden");
testRunner.setPageVisibility("hidden");
debug("first window: page is hidden");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
var testObject2 = { bar: 'y' };

if (window.internals && internals.dictionaryTest) {
var dictionaryTest = window.internals.dictionaryTest();
var dictionaryTest = internals.dictionaryTest();

debug('Test for setting an empty dictionary');
dictionaryTest.set({});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<script src="../resources/testharnessreport.js"></script>
<script>
setup(() => {
converter = window.internals.typeConversions();
converter = internals.typeConversions();
});

function verifyAttribute(attribute)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
var context = canvas.getContext("2d");
context.fillStyle = "red";
context.fillRect(0, 0, 200, 200);
window.internals.setPageScaleFactor(2);
window.internals.setVisualViewportOffset(200, 200);
internals.setPageScaleFactor(2);
internals.setVisualViewportOffset(200, 200);
requestAnimationFrame(() => {
testRunner.copyImageAtAndCapturePixelsAsyncThen(0, 0, (width, height, snapshot) => {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
testRunner.dumpAsText();
}
if (window.internals) {
window.internals.settings.setPreferCompositingToLCDTextEnabled(true);
internals.settings.setPreferCompositingToLCDTextEnabled(true);
}

function doScroll()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
var box = document.getElementById('box');
box.addEventListener('animationstart', function() {
if (window.testRunner) {
var layers = window.internals.layerTreeAsText(document);
var layers = internals.layerTreeAsText(document);
var result;
if (layers != "")
result = "PASS: created compositing layers when animating transform.";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@
return;

document.getElementById('animated').style.visibility = 'hidden';
window.internals.forceCompositingUpdate(document);
internals.forceCompositingUpdate(document);

documentLayerTree = JSON.parse(window.internals.layerTreeAsText(
documentLayerTree = JSON.parse(internals.layerTreeAsText(
document, window.internals.LAYER_TREE_INCLUDES_COMPOSITING_REASONS));

shouldBe('hiddenLayerIsComposited(documentLayerTree)', 'true');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
var t = async_test("Check that the preferCompositingToLCDText flag results in compositing");

function isUsingCompositedScrolling() {
var layers = JSON.parse(window.internals.layerTreeAsText(document));
var layers = JSON.parse(internals.layerTreeAsText(document));
var found = false;
layers["layers"].forEach(function(layer) {
if (layer.bounds[1] == 1000)
Expand All @@ -34,9 +34,9 @@
t.step(function() {
assert_not_equals(window.internals, null, 'This test requires window.internals');

window.internals.settings.setPreferCompositingToLCDTextEnabled(false);
internals.settings.setPreferCompositingToLCDTextEnabled(false);
var stateBefore = isUsingCompositedScrolling();
window.internals.settings.setPreferCompositingToLCDTextEnabled(true);
internals.settings.setPreferCompositingToLCDTextEnabled(true);
var stateAfter = isUsingCompositedScrolling();

assert_false(stateBefore, 'Composited scrolling began disabled');
Expand Down
Loading

0 comments on commit af4fa41

Please sign in to comment.