Bug 1325987 - Fix ESLint issues in devtools/server/tests/browser/. r=ntim

This commit is contained in:
Ruturaj K. Vartak 2017-02-23 20:32:00 -05:00
parent 7fcc6ce47a
commit 5db24589b8
51 changed files with 371 additions and 298 deletions

View file

@ -108,8 +108,6 @@ devtools/server/actors/object.js
devtools/server/actors/script.js
devtools/server/actors/styleeditor.js
devtools/server/actors/stylesheets.js
devtools/server/tests/browser/**
!devtools/server/tests/browser/browser_webextension_inspected_window.js
devtools/server/tests/mochitest/**
devtools/server/tests/unit/**
devtools/shared/heapsnapshot/**

View file

@ -161,9 +161,9 @@
<div class="multiple-animations-2"></div>
<div class="all-transitions"></div>
<script type="text/javascript">
"use strict";
// Get the transitions started when the page loads
var players;
addEventListener("load", function() {
addEventListener("load", function () {
document.querySelector(".transition").classList.add("get-round");
document.querySelector(".delayed-transition").classList.add("get-round");
});

View file

@ -1,32 +1,30 @@
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Check that the AnimationPlayerActor exposes a getFrames method that returns
// the list of keyframes in the animation.
const URL = MAIN_DOMAIN + "animation.html";
add_task(function* () {
let {client, walker, animations} =
yield initAnimationsFrontForUrl(MAIN_DOMAIN + "animation.html");
info("Get the test node and its animation front");
let node = yield walker.querySelector(walker.rootNode, ".simple-animation");
let [player] = yield animations.getAnimationPlayersForNode(node);
ok(player.getFrames, "The front has the getFrames method");
let frames = yield player.getFrames();
is(frames.length, 2, "The correct number of keyframes was retrieved");
ok(frames[0].transform, "Frame 0 has the transform property");
ok(frames[1].transform, "Frame 1 has the transform property");
// Note that we don't really test the content of the frame object here on
// purpose. This object comes straight out of the web animations API
// unmodified.
yield client.close();
gBrowser.removeCurrentTab();
});
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Check that the AnimationPlayerActor exposes a getFrames method that returns
// the list of keyframes in the animation.
add_task(function* () {
let {client, walker, animations} =
yield initAnimationsFrontForUrl(MAIN_DOMAIN + "animation.html");
info("Get the test node and its animation front");
let node = yield walker.querySelector(walker.rootNode, ".simple-animation");
let [player] = yield animations.getAnimationPlayersForNode(node);
ok(player.getFrames, "The front has the getFrames method");
let frames = yield player.getFrames();
is(frames.length, 2, "The correct number of keyframes was retrieved");
ok(frames[0].transform, "Frame 0 has the transform property");
ok(frames[1].transform, "Frame 1 has the transform property");
// Note that we don't really test the content of the frame object here on
// purpose. This object comes straight out of the web animations API
// unmodified.
yield client.close();
gBrowser.removeCurrentTab();
});

View file

@ -1,36 +1,36 @@
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Check that the AnimationPlayerActor exposes a getProperties method that
// returns the list of animated properties in the animation.
const URL = MAIN_DOMAIN + "animation.html";
add_task(function* () {
let {client, walker, animations} = yield initAnimationsFrontForUrl(URL);
info("Get the test node and its animation front");
let node = yield walker.querySelector(walker.rootNode, ".simple-animation");
let [player] = yield animations.getAnimationPlayersForNode(node);
ok(player.getProperties, "The front has the getProperties method");
let properties = yield player.getProperties();
is(properties.length, 1, "The correct number of properties was retrieved");
let propertyObject = properties[0];
is(propertyObject.name, "transform", "Property 0 is transform");
is(propertyObject.values.length, 2,
"The correct number of property values was retrieved");
// Note that we don't really test the content of the frame object here on
// purpose. This object comes straight out of the web animations API
// unmodified.
yield client.close();
gBrowser.removeCurrentTab();
});
/* vim: set ft=javascript ts=2 et sw=2 tw=80: */
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Check that the AnimationPlayerActor exposes a getProperties method that
// returns the list of animated properties in the animation.
const URL = MAIN_DOMAIN + "animation.html";
add_task(function* () {
let {client, walker, animations} = yield initAnimationsFrontForUrl(URL);
info("Get the test node and its animation front");
let node = yield walker.querySelector(walker.rootNode, ".simple-animation");
let [player] = yield animations.getAnimationPlayersForNode(node);
ok(player.getProperties, "The front has the getProperties method");
let properties = yield player.getProperties();
is(properties.length, 1, "The correct number of properties was retrieved");
let propertyObject = properties[0];
is(propertyObject.name, "transform", "Property 0 is transform");
is(propertyObject.values.length, 2,
"The correct number of property values was retrieved");
// Note that we don't really test the content of the frame object here on
// purpose. This object comes straight out of the web animations API
// unmodified.
yield client.close();
gBrowser.removeCurrentTab();
});

View file

@ -21,8 +21,10 @@ add_task(function* () {
info("Play a transition by adding the expand class, wait for mutations");
let onMutations = expectMutationEvents(animations, 2);
let cpow = content.document.querySelector(".all-transitions");
cpow.classList.add("expand");
yield ContentTask.spawn(gBrowser.selectedBrowser, {}, () => {
let el = content.document.querySelector(".all-transitions");
el.classList.add("expand");
});
let reportedMutations = yield onMutations;
is(reportedMutations.length, 2, "2 mutation events were received");
@ -35,7 +37,10 @@ add_task(function* () {
info("Play the transition back by removing the class, wait for mutations");
onMutations = expectMutationEvents(animations, 4);
cpow.classList.remove("expand");
yield ContentTask.spawn(gBrowser.selectedBrowser, {}, () => {
let el = content.document.querySelector(".all-transitions");
el.classList.remove("expand");
});
reportedMutations = yield onMutations;
is(reportedMutations.length, 4, "4 new mutation events were received");

View file

@ -41,9 +41,9 @@ add_task(function* () {
yield animations.setPlaybackRates(players, .5);
info("Query their states and check they are correct");
for (let player of players) {
let state = yield player.getCurrentState();
is(state.playbackRate, .5, "The playbackRate was updated");
for (let animPlayer of players) {
let animPlayerState = yield animPlayer.getCurrentState();
is(animPlayerState.playbackRate, .5, "The playbackRate was updated");
}
yield client.close();

View file

@ -19,6 +19,7 @@ const TEST_URL = "data:text/html;charset=utf-8,CanvasFrameAnonymousContentHelper
add_task(function* () {
let browser = yield addTab(TEST_URL);
// eslint-disable-next-line mozilla/no-cpows-in-tests
let doc = browser.contentDocument;
let nodeBuilder = () => {

View file

@ -19,6 +19,7 @@ const {
add_task(function* () {
let browser = yield addTab("about:preferences");
// eslint-disable-next-line mozilla/no-cpows-in-tests
let doc = browser.contentDocument;
let nodeBuilder = () => {

View file

@ -20,6 +20,7 @@ const TEST_URL = "data:text/html;charset=utf-8,CanvasFrameAnonymousContentHelper
add_task(function* () {
let browser = yield addTab(TEST_URL);
// eslint-disable-next-line mozilla/no-cpows-in-tests
let doc = browser.contentDocument;
let nodeBuilder = () => {
@ -97,6 +98,6 @@ function synthesizeMouseDown(x, y, win) {
// We need to make sure the inserted anonymous content can be targeted by the
// event right after having been inserted, and so we need to force a sync
// reflow.
let forceReflow = win.document.documentElement.offsetWidth;
win.document.documentElement.offsetWidth;
EventUtils.synthesizeMouseAtPoint(x, y, {type: "mousedown"}, win);
}

View file

@ -10,7 +10,6 @@
// This makes sure the 'domnode' protocol actor type is known when importing
// highlighter.
require("devtools/server/actors/inspector");
const events = require("sdk/event/core");
const {HighlighterEnvironment} = require("devtools/server/actors/highlighters");
@ -18,11 +17,14 @@ const {
CanvasFrameAnonymousContentHelper
} = require("devtools/server/actors/highlighters/utils/markup");
const TEST_URL_1 = "data:text/html;charset=utf-8,CanvasFrameAnonymousContentHelper test 1";
const TEST_URL_2 = "data:text/html;charset=utf-8,CanvasFrameAnonymousContentHelper test 2";
const TEST_URL_1 =
"data:text/html;charset=utf-8,CanvasFrameAnonymousContentHelper test 1";
const TEST_URL_2 =
"data:text/html;charset=utf-8,CanvasFrameAnonymousContentHelper test 2";
add_task(function* () {
let browser = yield addTab(TEST_URL_2);
let browser = yield addTab(TEST_URL_1);
// eslint-disable-next-line mozilla/no-cpows-in-tests
let doc = browser.contentDocument;
let nodeBuilder = () => {
@ -66,8 +68,9 @@ add_task(function* () {
info("Navigating to a new page");
let loaded = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
content.location = TEST_URL_2;
BrowserTestUtils.loadURI(browser, TEST_URL_2);
yield loaded;
// eslint-disable-next-line mozilla/no-cpows-in-tests
doc = gBrowser.selectedBrowser.contentWindow.document;
info("Try to access the element again");
@ -93,6 +96,6 @@ function synthesizeMouseDown(x, y, win) {
// We need to make sure the inserted anonymous content can be targeted by the
// event right after having been inserted, and so we need to force a sync
// reflow.
let forceReflow = win.document.documentElement.offsetWidth;
win.document.documentElement.offsetWidth;
EventUtils.synthesizeMouseAtPoint(x, y, {type: "mousedown"}, win);
}

View file

@ -21,6 +21,7 @@ const TEST_URL = "data:text/html;charset=utf-8,CanvasFrameAnonymousContentHelper
add_task(function* () {
let browser = yield addTab(TEST_URL);
// eslint-disable-next-line mozilla/no-cpows-in-tests
let doc = browser.contentDocument;
let nodeBuilder = () => {
@ -107,6 +108,6 @@ function synthesizeMouseDown(x, y, win) {
// We need to make sure the inserted anonymous content can be targeted by the
// event right after having been inserted, and so we need to force a sync
// reflow.
let forceReflow = win.document.documentElement.offsetWidth;
win.document.documentElement.offsetWidth;
EventUtils.synthesizeMouseAtPoint(x, y, {type: "mousedown"}, win);
}

View file

@ -21,6 +21,7 @@ const TEST_URL = "data:text/html;charset=utf-8,CanvasFrameAnonymousContentHelper
add_task(function* () {
let browser = yield addTab(TEST_URL);
// eslint-disable-next-line mozilla/no-cpows-in-tests
let doc = browser.contentDocument;
let nodeBuilder = () => {
@ -95,6 +96,6 @@ function synthesizeMouseDown(x, y, win) {
// We need to make sure the inserted anonymous content can be targeted by the
// event right after having been inserted, and so we need to force a sync
// reflow.
let forceReflow = win.document.documentElement.offsetWidth;
win.document.documentElement.offsetWidth;
EventUtils.synthesizeMouseAtPoint(x, y, {type: "mousedown"}, win);
}

View file

@ -8,8 +8,7 @@ const {DirectorManagerFront} = require("devtools/shared/fronts/director-manager"
const {DirectorRegistry} = require("devtools/server/actors/director-registry");
add_task(function* () {
let browser = yield addTab(MAIN_DOMAIN + "director-script-target.html");
let doc = browser.contentDocument;
yield addTab(MAIN_DOMAIN + "director-script-target.html");
initDebuggerServer();
let client = new DebuggerClient(DebuggerServer.connectPipe());
@ -50,8 +49,8 @@ function* testDirectorScriptMessagePort(directorManager) {
let { port } = yield installAndEnableDirectorScript(directorManager, {
scriptId: "testDirectorScript_MessagePort",
scriptCode: "(" + (function () {
exports.attach = function ({port}) {
port.onmessage = function (evt) {
exports.attach = function ({port: messagePort}) {
messagePort.onmessage = function (evt) {
// echo messages
evt.target.postMessage(evt.data);
};
@ -69,22 +68,23 @@ function* testDirectorScriptMessagePort(directorManager) {
// needs to explicit start the port
port.start();
var msg = { k1: "v1", k2: [1, 2, 3] };
let msg = { k1: "v1", k2: [1, 2, 3] };
port.postMessage(msg);
var reply = yield waitForMessagePortEvent;
let reply = yield waitForMessagePortEvent;
is(JSON.stringify(reply.data), JSON.stringify(msg), "echo reply received on the MessagePortClient");
is(JSON.stringify(reply.data), JSON.stringify(msg),
"echo reply received on the MessagePortClient");
}
function* testDirectorScriptWindowEval(directorManager) {
let { port } = yield installAndEnableDirectorScript(directorManager, {
scriptId: "testDirectorScript_WindowEval",
scriptCode: "(" + (function () {
exports.attach = function ({window, port}) {
var onpageloaded = function () {
var globalVarValue = window.eval("globalAccessibleVar;");
port.postMessage(globalVarValue);
exports.attach = function ({window, port: evalPort}) {
let onpageloaded = function () {
let globalVarValue = window.eval("globalAccessibleVar;");
evalPort.postMessage(globalVarValue);
};
if (window.document && window.document.readyState === "complete") {
@ -106,19 +106,20 @@ function* testDirectorScriptWindowEval(directorManager) {
// needs to explicit start the port
port.start();
var portEvent = yield waitForMessagePortEvent;
let portEvent = yield waitForMessagePortEvent;
ok(portEvent.data !== "unsecure-eval", "window.eval should be wrapped and safe");
is(portEvent.data, "global-value", "globalAccessibleVar should be accessible through window.eval");
is(portEvent.data, "global-value",
"globalAccessibleVar should be accessible through window.eval");
}
function* testDirectorScriptUnloadOnDetach(directorManager) {
let { port } = yield installAndEnableDirectorScript(directorManager, {
scriptId: "testDirectorScript_unloadOnDetach",
scriptCode: "(" + (function () {
exports.attach = function ({port, onUnload}) {
exports.attach = function ({port: unloadPort, onUnload}) {
onUnload(function () {
port.postMessage("ONUNLOAD");
unloadPort.postMessage("ONUNLOAD");
});
};
}).toString() + ")();",
@ -133,7 +134,8 @@ function* testDirectorScriptUnloadOnDetach(directorManager) {
let waitForDetach = once(directorManager, "director-script-detach");
let waitForMessage = once(port, "message");
directorManager.disableByScriptIds(["testDirectorScript_unloadOnDetach"], {reload: false});
directorManager.disableByScriptIds(["testDirectorScript_unloadOnDetach"],
{reload: false});
let { directorScriptId } = yield waitForDetach;
is(directorScriptId, "testDirectorScript_unloadOnDetach",

View file

@ -8,8 +8,7 @@ const {DirectorManagerFront} = require("devtools/shared/fronts/director-manager"
const {DirectorRegistry} = require("devtools/server/actors/director-registry");
add_task(function* () {
let browser = yield addTab(MAIN_DOMAIN + "director-script-target.html");
let doc = browser.contentDocument;
yield addTab(MAIN_DOMAIN + "director-script-target.html");
initDebuggerServer();
let client = new DebuggerClient(DebuggerServer.connectPipe());
@ -43,12 +42,13 @@ function* testErrorOnRequire(directorManager) {
assertIsDirectorScriptError(errorOnRequire);
let { message } = errorOnRequire;
is(message, "Error: NOT IMPLEMENTED", "error.message contains the expected error message");
is(message, "Error: NOT IMPLEMENTED",
"error.message contains the expected error message");
}
function* testErrorOnEvaluate(directorManager) {
// director scripts should send an error events if the director script raise an exception on
// evaluation
// director scripts should send an error events if the director script
// raise an exception on evaluation
let errorOnEvaluate = yield installAndEnableDirectorScript(directorManager, {
scriptId: "testDirectorScript_errorOnEvaluate",
scriptCode: "(" + (function () {
@ -62,8 +62,8 @@ function* testErrorOnEvaluate(directorManager) {
}
function* testErrorOnAttach(directorManager) {
// director scripts should send an error events if the director script raise an exception on
// evaluation
// director scripts should send an error events if the director script
// raise an exception on evaluation
let errorOnAttach = yield installAndEnableDirectorScript(directorManager, {
scriptId: "testDirectorScript_errorOnAttach",
scriptCode: "(" + (function () {
@ -79,9 +79,9 @@ function* testErrorOnAttach(directorManager) {
}
function* testErrorOnDetach(directorManager) {
// director scripts should send an error events if the director script raise an exception on
// evaluation
let attach = yield installAndEnableDirectorScript(directorManager, {
// director scripts should send an error events if the director script
// raise an exception on evaluation
yield installAndEnableDirectorScript(directorManager, {
scriptId: "testDirectorScript_errorOnDetach",
scriptCode: "(" + (function () {
module.exports = function ({onUnload}) {
@ -97,7 +97,8 @@ function* testErrorOnDetach(directorManager) {
let waitForDetach = once(directorManager, "director-script-detach");
let waitForError = once(directorManager, "director-script-error");
directorManager.disableByScriptIds(["testDirectorScript_errorOnDetach"], {reload: false});
directorManager.disableByScriptIds(["testDirectorScript_errorOnDetach"],
{reload: false});
let detach = yield waitForDetach;
let error = yield waitForError;

View file

@ -10,8 +10,7 @@ const {DirectorRegistry} = require("devtools/server/actors/director-registry");
DirectorRegistry.clear();
add_task(function* () {
let browser = yield addTab(MAIN_DOMAIN + "director-script-target.html");
let doc = browser.contentDocument;
yield addTab(MAIN_DOMAIN + "director-script-target.html");
initDebuggerServer();
let client = new DebuggerClient(DebuggerServer.connectPipe());

View file

@ -5,6 +5,7 @@
* Test that we get "nsCycleCollector::Collect" and
* "nsCycleCollector::ForgetSkippable" markers when we force cycle collection.
*/
"use strict";
const { PerformanceFront } = require("devtools/shared/fronts/performance");
@ -12,8 +13,7 @@ add_task(function* () {
// This test runs very slowly on linux32 debug EC2 instances.
requestLongerTimeout(2);
let browser = yield addTab(MAIN_DOMAIN + "doc_force_cc.html");
let doc = browser.contentDocument;
yield addTab(MAIN_DOMAIN + "doc_force_cc.html");
initDebuggerServer();
let client = new DebuggerClient(DebuggerServer.connectPipe());
@ -22,11 +22,14 @@ add_task(function* () {
yield front.connect();
let rec = yield front.startRecording({ withMarkers: true });
let markers = yield waitForMarkerType(front, ["nsCycleCollector::Collect", "nsCycleCollector::ForgetSkippable"]);
let markers = yield waitForMarkerType(front,
["nsCycleCollector::Collect", "nsCycleCollector::ForgetSkippable"]);
yield front.stopRecording(rec);
ok(markers.some(m => m.name === "nsCycleCollector::Collect"), "got some nsCycleCollector::Collect markers");
ok(markers.some(m => m.name === "nsCycleCollector::ForgetSkippable"), "got some nsCycleCollector::Collect markers");
ok(markers.some(m => m.name === "nsCycleCollector::Collect"),
"got some nsCycleCollector::Collect markers");
ok(markers.some(m => m.name === "nsCycleCollector::ForgetSkippable"),
"got some nsCycleCollector::Collect markers");
yield client.close();
gBrowser.removeCurrentTab();

View file

@ -4,12 +4,14 @@
/**
* Test that we get DOMContentLoaded and Load markers
*/
"use strict";
const { TimelineFront } = require("devtools/shared/fronts/timeline");
const MARKER_NAMES = ["document::DOMContentLoaded", "document::Load"];
add_task(function* () {
let browser = yield addTab(MAIN_DOMAIN + "doc_innerHTML.html");
// eslint-disable-next-line mozilla/no-cpows-in-tests
let doc = browser.contentDocument;
initDebuggerServer();

View file

@ -4,12 +4,14 @@
/**
* Test that we get DOMContentLoaded and Load markers
*/
"use strict";
const { TimelineFront } = require("devtools/shared/fronts/timeline");
const MARKER_NAMES = ["document::DOMContentLoaded", "document::Load"];
add_task(function* () {
let browser = yield addTab(MAIN_DOMAIN + "doc_innerHTML.html");
// eslint-disable-next-line mozilla/no-cpows-in-tests
let doc = browser.contentDocument;
initDebuggerServer();

View file

@ -4,12 +4,14 @@
/**
* Test that we get DOMContentLoaded and Load markers
*/
"use strict";
const { TimelineFront } = require("devtools/shared/fronts/timeline");
const MARKER_NAMES = ["document::DOMContentLoaded", "document::Load"];
add_task(function* () {
let browser = yield addTab(MAIN_DOMAIN + "doc_innerHTML.html");
// eslint-disable-next-line mozilla/no-cpows-in-tests
let doc = browser.contentDocument;
initDebuggerServer();

View file

@ -4,13 +4,13 @@
/**
* Test that we get "GarbageCollection" markers.
*/
"use strict";
const { PerformanceFront } = require("devtools/shared/fronts/performance");
const MARKER_NAME = "GarbageCollection";
add_task(function* () {
let browser = yield addTab(MAIN_DOMAIN + "doc_force_gc.html");
let doc = browser.contentDocument;
yield addTab(MAIN_DOMAIN + "doc_force_gc.html");
initDebuggerServer();
let client = new DebuggerClient(DebuggerServer.connectPipe());
@ -37,7 +37,8 @@ add_task(function* () {
return current.start;
}
if (current.start < previousStart) {
ok(false, `markers must be in order. ${current.name} marker has later start time (${current.start}) thanprevious: ${previousStart}`);
ok(false, `markers must be in order. ${current.name} marker has later\
start time (${current.start}) thanprevious: ${previousStart}`);
ordered = false;
}
return current.start;

View file

@ -5,6 +5,7 @@
* Test that we get "MinorGC" markers when we continue to steadily allocate
* objects.
*/
"use strict";
const { PerformanceFront } = require("devtools/shared/fronts/performance");
@ -12,7 +13,7 @@ add_task(function* () {
// This test runs very slowly on linux32 debug EC2 instances.
requestLongerTimeout(2);
let doc = yield addTab(MAIN_DOMAIN + "doc_allocations.html");
yield addTab(MAIN_DOMAIN + "doc_allocations.html");
initDebuggerServer();
let client = new DebuggerClient(DebuggerServer.connectPipe());

View file

@ -4,13 +4,13 @@
/**
* Test that we get "Parse HTML" markers.
*/
"use strict";
const { PerformanceFront } = require("devtools/shared/fronts/performance");
const MARKER_NAME = "Parse HTML";
add_task(function* () {
let browser = yield addTab(MAIN_DOMAIN + "doc_innerHTML.html");
let doc = browser.contentDocument;
yield addTab(MAIN_DOMAIN + "doc_innerHTML.html");
initDebuggerServer();
let client = new DebuggerClient(DebuggerServer.connectPipe());

View file

@ -4,13 +4,13 @@
/**
* Test that we get "Styles" markers with correct meta.
*/
"use strict";
const { PerformanceFront } = require("devtools/shared/fronts/performance");
const MARKER_NAME = "Styles";
add_task(function* () {
let browser = yield addTab(MAIN_DOMAIN + "doc_perf.html");
let doc = browser.contentDocument;
yield addTab(MAIN_DOMAIN + "doc_perf.html");
initDebuggerServer();
let client = new DebuggerClient(DebuggerServer.connectPipe());
@ -19,8 +19,8 @@ add_task(function* () {
yield front.connect();
let rec = yield front.startRecording({ withMarkers: true });
let markers = yield waitForMarkerType(front, MARKER_NAME, function (markers) {
return markers.some(({restyleHint}) => restyleHint != void 0);
let markers = yield waitForMarkerType(front, MARKER_NAME, function (marker) {
return marker.some(({restyleHint}) => restyleHint != void 0);
});
yield front.stopRecording(rec);

View file

@ -4,14 +4,15 @@
/**
* Test that we get a "TimeStamp" marker.
*/
"use strict";
const { PerformanceFront } = require("devtools/shared/fronts/performance");
const { pmmConsoleMethod, pmmLoadFrameScripts, pmmClearFrameScripts } = require("devtools/client/performance/test/helpers/profiler-mm-utils");
const { pmmConsoleMethod, pmmLoadFrameScripts, pmmClearFrameScripts }
= require("devtools/client/performance/test/helpers/profiler-mm-utils");
const MARKER_NAME = "TimeStamp";
add_task(function* () {
let browser = yield addTab(MAIN_DOMAIN + "doc_perf.html");
let doc = browser.contentDocument;
yield addTab(MAIN_DOMAIN + "doc_perf.html");
initDebuggerServer();
let client = new DebuggerClient(DebuggerServer.connectPipe());
@ -24,12 +25,14 @@ add_task(function* () {
pmmConsoleMethod("timeStamp");
pmmConsoleMethod("timeStamp", "myLabel");
let markers = yield waitForMarkerType(front, MARKER_NAME, markers => markers.length >= 2);
let markers = yield waitForMarkerType(front, MARKER_NAME, m => m.length >= 2);
yield front.stopRecording(rec);
ok(markers.every(({stack}) => typeof stack === "number"), "All markers have stack references.");
ok(markers.every(({name}) => name === "TimeStamp"), "All markers found are TimeStamp markers");
ok(markers.every(({stack}) => typeof stack === "number"),
"All markers have stack references.");
ok(markers.every(({name}) => name === "TimeStamp"),
"All markers found are TimeStamp markers");
ok(markers.length === 2, "found 2 TimeStamp markers");
ok(markers.every(({start, end}) => typeof start === "number" && start === end),
"All markers have equal start and end times");

View file

@ -10,50 +10,56 @@ const URL2 = MAIN_DOMAIN + "navigate-second.html";
var events = require("sdk/event/core");
var client;
SpecialPowers.pushPrefEnv({"set": [["dom.require_user_interaction_for_beforeunload", false]]});
SpecialPowers.pushPrefEnv(
{"set": [["dom.require_user_interaction_for_beforeunload", false]]});
// State machine to check events order
var i = 0;
function assertEvent(event, data) {
let x = 0;
switch (i++) {
case x++:
case 0:
is(event, "request", "Get first page load");
is(data, URL1);
break;
case x++:
case 1:
is(event, "load-new-document", "Ask to load the second page");
break;
case x++:
case 2:
is(event, "unload-dialog", "We get the dialog on first page unload");
break;
case x++:
case 3:
is(event, "will-navigate", "The very first event is will-navigate on server side");
is(data.newURI, URL2, "newURI property is correct");
break;
case x++:
is(event, "request", "RDP is async with messageManager, the request happens after will-navigate");
case 4:
is(event, "request",
"RDP is async with messageManager, the request happens after will-navigate");
is(data, URL2);
break;
case x++:
case 5:
is(event, "tabNavigated", "After the request, the client receive tabNavigated");
is(data.state, "start", "state is start");
is(data.url, URL2, "url property is correct");
is(data.nativeConsoleAPI, true, "nativeConsoleAPI is correct");
break;
case x++:
case 6:
is(event, "DOMContentLoaded");
// eslint-disable-next-line mozilla/no-cpows-in-tests
is(content.document.readyState, "interactive");
break;
case x++:
case 7:
is(event, "load");
// eslint-disable-next-line mozilla/no-cpows-in-tests
is(content.document.readyState, "complete");
break;
case x++:
is(event, "navigate", "Then once the second doc is loaded, we get the navigate event");
is(content.document.readyState, "complete", "navigate is emitted only once the document is fully loaded");
case 8:
is(event, "navigate",
"Then once the second doc is loaded, we get the navigate event");
// eslint-disable-next-line mozilla/no-cpows-in-tests
is(content.document.readyState, "complete",
"navigate is emitted only once the document is fully loaded");
break;
case x++:
case 9:
is(event, "tabNavigated", "Finally, the receive the client event");
is(data.state, "stop", "state is stop");
is(data.url, URL2, "url property is correct");
@ -102,22 +108,21 @@ function getServerTabActor(callback) {
client = new DebuggerClient(transport);
connectDebuggerClient(client).then(form => {
let actorID = form.actor;
client.attachTab(actorID, function (aResponse, aTabClient) {
client.attachTab(actorID, function (response, tabClient) {
// !Hack! Retrieve a server side object, the BrowserTabActor instance
let tabActor = DebuggerServer._searchAllConnectionsForActor(actorID);
callback(tabActor);
});
});
client.addListener("tabNavigated", function (aEvent, aPacket) {
assertEvent("tabNavigated", aPacket);
client.addListener("tabNavigated", function (event, packet) {
assertEvent("tabNavigated", packet);
});
}
function test() {
// Open a test tab
addTab(URL1).then(function (browser) {
let doc = browser.contentDocument;
getServerTabActor(function (tabActor) {
// In order to listen to internal will-navigate/navigate events
events.on(tabActor, "will-navigate", function (data) {
@ -140,9 +145,8 @@ function test() {
// Load another document in this doc to dispatch these events
assertEvent("load-new-document");
content.location = URL2;
BrowserTestUtils.loadURI(gBrowser.selectedBrowser, URL2);
});
});
}

View file

@ -5,11 +5,12 @@
* Test that we have allocation data coming from the front.
*/
"use strict";
const { PerformanceFront } = require("devtools/shared/fronts/performance");
add_task(function* () {
let browser = yield addTab(MAIN_DOMAIN + "doc_allocations.html");
let doc = browser.contentDocument;
yield addTab(MAIN_DOMAIN + "doc_allocations.html");
initDebuggerServer();
let client = new DebuggerClient(DebuggerServer.connectPipe());
@ -17,7 +18,8 @@ add_task(function* () {
let front = PerformanceFront(client, form);
yield front.connect();
let rec = yield front.startRecording({ withMarkers: true, withAllocations: true, withTicks: true });
let rec = yield front.startRecording(
{ withMarkers: true, withAllocations: true, withTicks: true });
yield waitUntil(() => rec.getAllocations().frames.length);
yield waitUntil(() => rec.getAllocations().timestamps.length);
@ -26,10 +28,11 @@ add_task(function* () {
yield front.stopRecording(rec);
let { frames, timestamps, sizes, sites } = rec.getAllocations();
let { timestamps, sizes } = rec.getAllocations();
is(timestamps.length, sizes.length, "we have the same amount of timestamps and sizes");
ok(timestamps.every(time => time > 0 && typeof time === "number"), "all timestamps have numeric values");
ok(timestamps.every(time => time > 0 && typeof time === "number"),
"all timestamps have numeric values");
ok(sizes.every(n => n > 0 && typeof n === "number"), "all sizes are positive numbers");
yield front.destroy();

View file

@ -7,12 +7,13 @@
* a recording is stopped.
*/
"use strict";
const { PerformanceFront } = require("devtools/shared/fronts/performance");
const { pmmIsProfilerActive, pmmStopProfiler, pmmLoadFrameScripts } = require("devtools/client/performance/test/helpers/profiler-mm-utils");
const { pmmIsProfilerActive, pmmLoadFrameScripts } = require("devtools/client/performance/test/helpers/profiler-mm-utils");
add_task(function* () {
let browser = yield addTab(MAIN_DOMAIN + "doc_perf.html");
let doc = browser.contentDocument;
yield addTab(MAIN_DOMAIN + "doc_perf.html");
initDebuggerServer();
let client = new DebuggerClient(DebuggerServer.connectPipe());

View file

@ -6,8 +6,10 @@
* is destroyed if there are other consumers using it.
*/
"use strict";
const { PerformanceFront } = require("devtools/shared/fronts/performance");
const { pmmIsProfilerActive, pmmStopProfiler, pmmLoadFrameScripts } = require("devtools/client/performance/test/helpers/profiler-mm-utils");
const { pmmIsProfilerActive, pmmLoadFrameScripts } = require("devtools/client/performance/test/helpers/profiler-mm-utils");
add_task(function* () {
yield addTab(MAIN_DOMAIN + "doc_perf.html");

View file

@ -8,8 +8,10 @@
* addon was installed and automatically activated the profiler module).
*/
"use strict";
const { PerformanceFront } = require("devtools/shared/fronts/performance");
const { pmmIsProfilerActive, pmmStartProfiler, pmmStopProfiler, pmmLoadFrameScripts, pmmClearFrameScripts } = require("devtools/client/performance/test/helpers/profiler-mm-utils");
const { pmmIsProfilerActive, pmmStartProfiler, pmmLoadFrameScripts, pmmClearFrameScripts } = require("devtools/client/performance/test/helpers/profiler-mm-utils");
add_task(function* () {
// Ensure the profiler is already running when the test starts.
@ -29,7 +31,7 @@ add_task(function* () {
let firstFront = PerformanceFront(client, form);
yield firstFront.connect();
let recording = yield firstFront.startRecording();
yield firstFront.startRecording();
yield addTab(MAIN_DOMAIN + "doc_perf.html");
let client2 = new DebuggerClient(DebuggerServer.connectPipe());

View file

@ -5,11 +5,12 @@
* Test functionality of real time markers.
*/
"use strict";
const { PerformanceFront } = require("devtools/shared/fronts/performance");
add_task(function* () {
let browser = yield addTab(MAIN_DOMAIN + "doc_perf.html");
let doc = browser.contentDocument;
yield addTab(MAIN_DOMAIN + "doc_perf.html");
initDebuggerServer();
let client = new DebuggerClient(DebuggerServer.connectPipe());
@ -34,7 +35,8 @@ add_task(function* () {
front.on("timeline-data", handler);
let rec = yield front.startRecording({ withMarkers: true, withMemory: true, withTicks: true });
let rec = yield front.startRecording(
{ withMarkers: true, withMemory: true, withTicks: true });
yield Promise.all(Object.keys(deferreds).map(type => deferreds[type].promise));
yield front.stopRecording(rec);
front.off("timeline-data", handler);
@ -49,15 +51,18 @@ add_task(function* () {
function handler(name, data) {
if (name === "markers") {
if (counters.markers.length >= 1) { return; }
if (counters.markers.length >= 1) {
return;
}
ok(data.markers[0].start, "received atleast one marker with `start`");
ok(data.markers[0].end, "received atleast one marker with `end`");
ok(data.markers[0].name, "received atleast one marker with `name`");
counters.markers.push(data.markers);
}
else if (name === "memory") {
if (counters.memory.length >= 3) { return; }
} else if (name === "memory") {
if (counters.memory.length >= 3) {
return;
}
let { delta, measurement } = data;
is(typeof delta, "number", "received `delta` in memory event");
ok(delta > lastMemoryDelta, "received `delta` in memory event");
@ -65,9 +70,10 @@ add_task(function* () {
counters.memory.push({ delta, measurement });
lastMemoryDelta = delta;
}
else if (name === "ticks") {
if (counters.ticks.length >= 3) { return; }
} else if (name === "ticks") {
if (counters.ticks.length >= 3) {
return;
}
let { delta, timestamps } = data;
ok(delta > lastTickDelta, "received `delta` in ticks event");
@ -76,11 +82,9 @@ add_task(function* () {
counters.ticks.push({ delta, timestamps });
lastTickDelta = delta;
}
else if (name === "frames") {
} else if (name === "frames") {
// Nothing to do here.
}
else {
} else {
ok(false, `Received unknown event: ${name}`);
}

View file

@ -6,11 +6,12 @@
* completed, and rec data.
*/
"use strict";
const { PerformanceFront } = require("devtools/shared/fronts/performance");
add_task(function* () {
let browser = yield addTab(MAIN_DOMAIN + "doc_perf.html");
let doc = browser.contentDocument;
yield addTab(MAIN_DOMAIN + "doc_perf.html");
initDebuggerServer();
let client = new DebuggerClient(DebuggerServer.connectPipe());
@ -18,7 +19,8 @@ add_task(function* () {
let front = PerformanceFront(client, form);
yield front.connect();
let rec = yield front.startRecording({ withMarkers: true, withTicks: true, withMemory: true });
let rec = yield front.startRecording(
{ withMarkers: true, withTicks: true, withMemory: true });
ok(rec.isRecording(), "RecordingModel is recording when created");
yield busyWait(100);
yield waitUntil(() => rec.getMemory().length);
@ -43,7 +45,8 @@ add_task(function* () {
ok(rec.isCompleted(), "recording is completed once it has profile data");
} else {
ok(!rec.isCompleted(), "recording is not yet completed on 'recording-stopping'");
ok(rec.isFinalizing(), "recording is considered finalizing between 'recording-stopping' and 'recording-stopped'");
ok(rec.isFinalizing(),
"recording is finalized between 'recording-stopping' and 'recording-stopped'");
}
yield stopped;

View file

@ -5,14 +5,15 @@
* Test that buffer status is correctly updated in recording models.
*/
"use strict";
var BUFFER_SIZE = 20000;
var config = { bufferSize: BUFFER_SIZE };
const { PerformanceFront } = require("devtools/shared/fronts/performance");
add_task(function* () {
let browser = yield addTab(MAIN_DOMAIN + "doc_perf.html");
let doc = browser.contentDocument;
yield addTab(MAIN_DOMAIN + "doc_perf.html");
initDebuggerServer();
let client = new DebuggerClient(DebuggerServer.connectPipe());
@ -23,8 +24,10 @@ add_task(function* () {
yield front.setProfilerStatusInterval(10);
let model = yield front.startRecording(config);
let stats = yield once(front, "profiler-status");
is(stats.totalSize, BUFFER_SIZE, `profiler-status event has totalSize: ${stats.totalSize}`);
ok(stats.position < BUFFER_SIZE, `profiler-status event has position: ${stats.position}`);
is(stats.totalSize, BUFFER_SIZE,
`profiler-status event has totalSize: ${stats.totalSize}`);
ok(stats.position < BUFFER_SIZE,
`profiler-status event has position: ${stats.position}`);
ok(stats.generation >= 0, `profiler-status event has generation: ${stats.generation}`);
ok(stats.isActive, "profiler-status event is isActive");
is(typeof stats.currentTime, "number", "profiler-status event has currentTime");
@ -36,7 +39,8 @@ add_task(function* () {
let checkCount = 0;
while (lastBufferStatus < 1) {
let currentBufferStatus = front.getBufferUsageForRecording(model);
ok(currentBufferStatus > lastBufferStatus, `buffer is more filled than before: ${currentBufferStatus} > ${lastBufferStatus}`);
ok(currentBufferStatus > lastBufferStatus,
`buffer is more filled than before: ${currentBufferStatus} > ${lastBufferStatus}`);
lastBufferStatus = currentBufferStatus;
checkCount++;
yield once(front, "profiler-status");
@ -46,7 +50,8 @@ add_task(function* () {
is(lastBufferStatus, 1, "buffer usage cannot surpass 100%");
yield front.stopRecording(model);
is(front.getBufferUsageForRecording(model), null, "buffer usage should be null when no longer recording.");
is(front.getBufferUsageForRecording(model), null,
"buffer usage should be null when no longer recording.");
yield front.destroy();
yield client.close();

View file

@ -6,13 +6,15 @@
* normalized before passed to consumers.
*/
const WAIT_TIME = 1000; // ms
"use strict";
// time in ms
const WAIT_TIME = 1000;
const { PerformanceFront } = require("devtools/shared/fronts/performance");
add_task(function* () {
let browser = yield addTab(MAIN_DOMAIN + "doc_perf.html");
let doc = browser.contentDocument;
yield addTab(MAIN_DOMAIN + "doc_perf.html");
initDebuggerServer();
let client = new DebuggerClient(DebuggerServer.connectPipe());
@ -26,7 +28,8 @@ add_task(function* () {
let firstRecordingStartTime = firstRecording._startTime;
info("Started profiling at: " + firstRecordingStartTime);
busyWait(WAIT_TIME); // allow the profiler module to sample some cpu activity
// allow the profiler module to sample some cpu activity
busyWait(WAIT_TIME);
yield front.stopRecording(firstRecording);
@ -39,7 +42,8 @@ add_task(function* () {
let secondRecordingStartTime = secondRecording._startTime;
info("Started profiling at: " + secondRecordingStartTime);
busyWait(WAIT_TIME); // allow the profiler module to sample more cpu activity
// allow the profiler module to sample more cpu activity
busyWait(WAIT_TIME);
yield front.stopRecording(secondRecording);
let secondRecordingProfile = secondRecording.getProfile();
@ -53,7 +57,9 @@ add_task(function* () {
"The second recorded sample times were normalized.");
ok(secondRecordingSamples[0][TIME_SLOT] > 0,
"The second recorded sample times were normalized correctly.");
ok(!secondRecordingSamples.find(e => e[TIME_SLOT] + secondRecordingStartTime <= firstRecording.getDuration()),
ok(!secondRecordingSamples.find(
e => e[TIME_SLOT] + secondRecordingStartTime <= firstRecording.getDuration()
),
"There should be no samples from the first recording in the second one, " +
"even though the total number of frames did not overflow.");

View file

@ -7,13 +7,15 @@
* devtools/client/performance/modules/logic/tree-model.js will have to be changed.
*/
const WAIT_TIME = 1000; // ms
"use strict";
// Time in ms
const WAIT_TIME = 1000;
const { PerformanceFront } = require("devtools/shared/fronts/performance");
add_task(function* () {
let browser = yield addTab(MAIN_DOMAIN + "doc_perf.html");
let doc = browser.contentDocument;
yield addTab(MAIN_DOMAIN + "doc_perf.html");
initDebuggerServer();
let client = new DebuggerClient(DebuggerServer.connectPipe());
@ -22,7 +24,8 @@ add_task(function* () {
yield front.connect();
let rec = yield front.startRecording();
busyWait(WAIT_TIME); // allow the profiler module to sample some cpu activity
// allow the profiler module to sample some cpu activity
busyWait(WAIT_TIME);
yield front.stopRecording(rec);
let profile = rec.getProfile();

View file

@ -1,9 +1,11 @@
"use strict";
var gClient;
function test() {
waitForExplicitFinish();
var {ActorRegistryFront} = require("devtools/shared/fronts/actor-registry");
var actorURL = "chrome://mochitests/content/chrome/devtools/server/tests/mochitest/hello-actor.js";
let {ActorRegistryFront} = require("devtools/shared/fronts/actor-registry");
let actorURL = "chrome://mochitests/content/chrome/devtools/server/tests/mochitest/hello-actor.js";
if (!DebuggerServer.initialized) {
DebuggerServer.init();
@ -13,64 +15,60 @@ function test() {
gClient = new DebuggerClient(DebuggerServer.connectPipe());
gClient.connect()
.then(() => gClient.listTabs())
.then(aResponse => {
var options = {
.then(response => {
let options = {
prefix: "helloActor",
constructor: "HelloActor",
type: { tab: true }
};
var registry = ActorRegistryFront(gClient, aResponse);
let registry = ActorRegistryFront(gClient, response);
registry.registerActor(actorURL, options).then(actorFront => {
gClient.listTabs(response => {
var tab = response.tabs[response.selected];
gClient.listTabs(res => {
let tab = res.tabs[res.selected];
ok(!!tab.helloActor, "Hello actor must exist");
// Make sure actor's state is maintained across listTabs requests.
checkActorState(tab.helloActor, () => {
// Clean up
actorFront.unregister().then(() => {
gClient.close().then(() => {
DebuggerServer.destroy();
gClient = null;
finish();
});
});
});
checkActorState(tab.helloActor, cleanupActor.bind(this, actorFront));
});
});
});
}
function checkActorState(helloActor, callback) {
getCount(helloActor, response => {
ok(!response.error, "No error");
is(response.count, 1, "The counter must be valid");
getCount(helloActor, response => {
ok(!response.error, "No error");
is(response.count, 2, "The counter must be valid");
gClient.listTabs(response => {
var tab = response.tabs[response.selected];
is(tab.helloActor, helloActor, "Hello actor must be valid");
getCount(helloActor, response => {
ok(!response.error, "No error");
is(response.count, 3, "The counter must be valid");
callback();
});
});
function cleanupActor(actorFront) {
// Clean up
actorFront.unregister().then(() => {
gClient.close().then(() => {
DebuggerServer.destroy();
gClient = null;
finish();
});
});
}
function getCount(actor, callback) {
gClient.request({
return gClient.request({
to: actor,
type: "count"
}, callback);
}
var checkActorState = Task.async(function* (helloActor, callback) {
let response = yield getCount(helloActor);
ok(!response.error, "No error");
is(response.count, 1, "The counter must be valid");
response = yield getCount(helloActor);
ok(!response.error, "No error");
is(response.count, 2, "The counter must be valid");
let {tabs, selected} = yield gClient.listTabs();
let tab = tabs[selected];
is(tab.helloActor, helloActor, "Hello actor must be valid");
response = yield getCount(helloActor);
ok(!response.error, "No error");
is(response.count, 3, "The counter must be valid");
callback();
});

View file

@ -163,8 +163,10 @@ function testAddIframe(front) {
front.on("stores-update", onStoresUpdate);
// eslint-disable-next-line mozilla/no-cpows-in-tests
let iframe = content.document.createElement("iframe");
iframe.src = ALT_DOMAIN_SECURED + "storage-secured-iframe.html";
// eslint-disable-next-line mozilla/no-cpows-in-tests
content.document.querySelector("body").appendChild(iframe);
});
}
@ -229,12 +231,14 @@ function testRemoveIframe(front) {
front.on("stores-update", onStoresUpdate);
for (let iframe of content.document.querySelectorAll("iframe")) {
if (iframe.src.startsWith("http:")) {
iframe.remove();
break;
ContentTask.spawn(gBrowser.selectedBrowser, {}, () => {
for (let iframe of content.document.querySelectorAll("iframe")) {
if (iframe.src.startsWith("http:")) {
iframe.remove();
break;
}
}
}
});
});
}

View file

@ -228,7 +228,7 @@ const IDBValues = {
},
]
},
"http://sectest1.example.org" : {},
"http://sectest1.example.org": {},
"https://sectest1.example.org": {
"idb-s1 (default)": [
{
@ -297,7 +297,7 @@ const IDBValues = {
],
"idb2 (default)#obj3": []
},
"http://sectest1.example.org" : {},
"http://sectest1.example.org": {},
"https://sectest1.example.org": {
"idb-s1 (default)#obj-s1": [
{
@ -331,13 +331,6 @@ const IDBValues = {
}
};
function finishTests(client) {
let closeConnection = () => {
};
}
function* testStores(data) {
ok(data.cookies, "Cookies storage actor is present");
ok(data.localStorage, "Local Storage storage actor is present");
@ -514,8 +507,8 @@ var testIndexedDBs = Task.async(function* (index, hosts, indexedDBActor) {
yield testIndexedDBs(++index, hosts, indexedDBActor);
});
var testObjectStores = Task.async(function* (index, hosts, indexedDBActor) {
let host = Object.keys(hosts)[index];
var testObjectStores = Task.async(function* (ix, hosts, indexedDBActor) {
let host = Object.keys(hosts)[ix];
let matchItems = (data, db) => {
is(data.total, IDBValues.objectStoreDetails[host][db].length,
"Number of object stores in host " + host + " matches");
@ -559,10 +552,10 @@ var testObjectStores = Task.async(function* (index, hosts, indexedDBActor) {
yield indexedDBActor.getStoreObjects(host, [JSON.stringify(objName)])
), objName[0]);
}
if (index == Object.keys(hosts).length - 1) {
if (ix == Object.keys(hosts).length - 1) {
return;
}
yield testObjectStores(++index, hosts, indexedDBActor);
yield testObjectStores(++ix, hosts, indexedDBActor);
});
var testIDBEntries = Task.async(function* (index, hosts, indexedDBActor) {

View file

@ -5,11 +5,6 @@
"use strict";
const {StorageFront} = require("devtools/shared/fronts/storage");
const beforeReload = {
cookies: ["http://test1.example.org", "https://sectest1.example.org"],
localStorage: ["http://test1.example.org", "http://sectest1.example.org"],
sessionStorage: ["http://test1.example.org", "http://sectest1.example.org"],
};
const TESTS = [
// index 0
@ -303,6 +298,7 @@ function* finishTests(client) {
add_task(function* () {
let browser = yield addTab(MAIN_DOMAIN + "storage-updates.html");
// eslint-disable-next-line mozilla/no-cpows-in-tests
let doc = browser.contentDocument;
initDebuggerServer();

View file

@ -10,8 +10,7 @@
const {StyleSheetsFront} = require("devtools/shared/fronts/stylesheets");
add_task(function* () {
let browser = yield addTab(MAIN_DOMAIN + "stylesheets-nested-iframes.html");
let doc = browser.contentDocument;
yield addTab(MAIN_DOMAIN + "stylesheets-nested-iframes.html");
info("Initialising the debugger server and client.");
initDebuggerServer();

View file

@ -13,8 +13,7 @@
const {TimelineFront} = require("devtools/shared/fronts/timeline");
add_task(function* () {
let browser = yield addTab("data:text/html;charset=utf-8,mop");
let doc = browser.contentDocument;
yield addTab("data:text/html;charset=utf-8,mop");
initDebuggerServer();
let client = new DebuggerClient(DebuggerServer.connectPipe());
@ -27,7 +26,10 @@ add_task(function* () {
ok(!isActive, "The TimelineFront is not initially recording");
info("Flush any pending reflows");
let forceSyncReflow = doc.body.innerHeight;
ContentTask.spawn(gBrowser.selectedBrowser, {}, () => {
// forceSyncReflow
content.document.body.innerHeight;
});
info("Start recording");
yield front.start({ withMarkers: true });
@ -37,18 +39,25 @@ add_task(function* () {
info("Change some style on the page to cause style/reflow/paint");
let onMarkers = once(front, "markers");
doc.body.style.padding = "10px";
ContentTask.spawn(gBrowser.selectedBrowser, {}, () => {
content.document.body.style.padding = "10px";
});
let markers = yield onMarkers;
ok(true, "The markers event was fired");
ok(markers.length > 0, "Markers were returned");
info("Flush pending reflows again");
forceSyncReflow = doc.body.innerHeight;
ContentTask.spawn(gBrowser.selectedBrowser, {}, () => {
// forceSyncReflow
content.document.body.innerHeight;
});
info("Change some style on the page to cause style/paint");
onMarkers = once(front, "markers");
doc.body.style.backgroundColor = "red";
ContentTask.spawn(gBrowser.selectedBrowser, {}, () => {
content.document.body.style.backgroundColor = "red";
});
markers = yield onMarkers;
ok(markers.length > 0, "markers were returned");

View file

@ -10,8 +10,7 @@
const {TimelineFront} = require("devtools/shared/fronts/timeline");
add_task(function* () {
let browser = yield addTab("data:text/html;charset=utf-8,mop");
let doc = browser.contentDocument;
yield addTab("data:text/html;charset=utf-8,mop");
initDebuggerServer();
let client = new DebuggerClient(DebuggerServer.connectPipe());

View file

@ -10,8 +10,7 @@
const {TimelineFront} = require("devtools/shared/fronts/timeline");
add_task(function* () {
let browser = yield addTab(MAIN_DOMAIN + "timeline-iframe-parent.html");
let doc = browser.contentDocument;
yield addTab(MAIN_DOMAIN + "timeline-iframe-parent.html");
initDebuggerServer();
let client = new DebuggerClient(DebuggerServer.connectPipe());
@ -24,7 +23,8 @@ add_task(function* () {
// Check that we get markers for a few iterations of the timer that runs in
// the child frame.
for (let i = 0; i < 3; i++) {
yield wait(300); // That's the time the child frame waits before changing styles.
// That's the time the child frame waits before changing styles.
yield wait(300);
let markers = yield once(front, "markers");
ok(markers.length, "Markers were received for operations in the child frame");
}

View file

@ -1,11 +1,13 @@
<html>
<head>
<script>
// change the eval function to ensure the window object in the debug-script is correctly wrapped
/* exported globalAccessibleVar */
"use strict";
// change the eval function to ensure the window object
// in the debug-script is correctly wrapped
window.eval = function () {
return "unsecure-eval-called";
};
var globalAccessibleVar = "global-value";
</script>
</head>

View file

@ -5,11 +5,13 @@
</head>
<body>
<script>
"use strict";
window.allocs = [];
window.onload = function() {
window.onload = function () {
function allocator() {
for (var i = 0; i < 1000; i++) {
window.allocs.push(new Object);
for (let i = 0; i < 1000; i++) {
window.allocs.push(new Object());
}
}

View file

@ -10,6 +10,8 @@
<body>
<script type="text/javascript">
"use strict";
window.test = function () {
document.body.expando1 = { cycle: document.body };
SpecialPowers.Cu.forceCC();

View file

@ -10,12 +10,15 @@
<body>
<script type="text/javascript">
"use strict";
var x = 1;
window.test = function () {
SpecialPowers.Cu.forceGC();
document.body.style.borderTop = x + "px solid red";
x = 1^x;
document.body.innerHeight; // flush pending reflows
x = 1 ^ x;
// flush pending reflows
document.body.innerHeight;
// Prevent this script from being garbage collected.
setTimeout(window.test, 100);

View file

@ -10,11 +10,14 @@
<body>
<script type="text/javascript">
"use strict";
var x = 1;
function test() {
document.body.style.borderTop = x + "px solid red";
x = 1^x;
document.body.innerHeight; // flush pending reflows
x = 1 ^ x;
// flush pending reflows
document.body.innerHeight;
}
// Prevent this script from being garbage collected.

View file

@ -6,9 +6,9 @@
<body>
First
<script>
window.onbeforeunload=function(e){
e.returnValue="?";
"use strict";
window.onbeforeunload = function (e) {
e.returnValue = "?";
};
</script>
</body>

View file

@ -1,6 +1,8 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/* exported openTabAndSetupStorage, clearStorage */
"use strict";
/**

View file

@ -8,6 +8,7 @@ Iframe for testing multiple host detetion in storage actor
</head>
<body>
<script>
"use strict";
document.cookie = "uc1=foobar; domain=.example.org; path=/; secure=true";
localStorage.setItem("iframe-u-ls1", "foobar");
@ -15,12 +16,13 @@ sessionStorage.setItem("iframe-u-ss1", "foobar1");
sessionStorage.setItem("iframe-u-ss2", "foobar2");
console.log("added cookies and stuff from unsecured iframe");
window.clear = function*() {
window.clear = function* () {
document.cookie = "uc1=; expires=Thu, 01 Jan 1970 00:00:00 GMT";
localStorage.clear();
sessionStorage.clear();
console.log("removed cookies and stuff from unsecured iframe");
}
};
</script>
</body>
</html>

View file

@ -7,12 +7,13 @@
<body>
<h1>Child frame</h1>
<script>
"use strict";
var h1 = document.querySelector("h1");
setInterval(function() {
h1.style.backgroundColor = "rgb(" + ((Math.random()*255)|0) + "," +
((Math.random()*255)|0) + "," +
((Math.random()*255)|0) +")";
h1.style.width = ((Math.random()*500)|0) + "px";
setInterval(function () {
h1.style.backgroundColor = "rgb(" + ((Math.random() * 255)|0) + "," +
((Math.random() * 255)|0) + "," +
((Math.random() * 255)|0) + ")";
h1.style.width = ((Math.random() * 500)|0) + "px";
}, 300);
</script>
</body>