forked from Floorp-Projects/Floorp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 1456098 - Create tests for devtools.main.activate telemetry event…
… r=yulia MozReview-Commit-ID: III7oI427vr
- Loading branch information
Michael Ratcliffe
committed
Apr 25, 2018
1 parent
07c56c0
commit 7eacd81
Showing
4 changed files
with
165 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
devtools/client/framework/test/browser_toolbox_telemetry_activate_splitconsole.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* Any copyright is dedicated to the Public Domain. | ||
* http://creativecommons.org/publicdomain/zero/1.0/ */ | ||
|
||
"use strict"; | ||
|
||
const URL = | ||
"data:text/html;charset=utf8,browser_toolbox_telemetry_activate_splitconsole.js"; | ||
const OPTOUT = Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTOUT; | ||
const DATA = [ | ||
{ | ||
timestamp: null, | ||
category: "devtools.main", | ||
method: "activate", | ||
object: "split_console", | ||
value: null, | ||
extra: { | ||
host: "bottom", | ||
width: "1300" | ||
} | ||
}, { | ||
timestamp: null, | ||
category: "devtools.main", | ||
method: "activate", | ||
object: "split_console", | ||
value: null, | ||
extra: { | ||
host: "bottom", | ||
width: "1300" | ||
} | ||
} | ||
]; | ||
|
||
add_task(async function() { | ||
// Let's reset the counts. | ||
Services.telemetry.clearEvents(); | ||
|
||
// Ensure no events have been logged | ||
const snapshot = Services.telemetry.snapshotEvents(OPTOUT, true); | ||
ok(!snapshot.parent, "No events have been logged for the main process"); | ||
|
||
const tab = await addTab(URL); | ||
const target = TargetFactory.forTab(tab); | ||
const toolbox = await gDevTools.showToolbox(target, "inspector"); | ||
|
||
await toolbox.openSplitConsole(); | ||
await toolbox.closeSplitConsole(); | ||
await toolbox.openSplitConsole(); | ||
await toolbox.closeSplitConsole(); | ||
|
||
await checkResults(); | ||
}); | ||
|
||
async function checkResults() { | ||
const snapshot = Services.telemetry.snapshotEvents(OPTOUT, true); | ||
const events = snapshot.parent.filter(event => event[1] === "devtools.main" && | ||
event[2] === "activate" && | ||
event[4] === null | ||
); | ||
|
||
for (let i in DATA) { | ||
const [ timestamp, category, method, object, value, extra ] = events[i]; | ||
const expected = DATA[i]; | ||
|
||
// ignore timestamp | ||
ok(timestamp > 0, "timestamp is greater than 0"); | ||
is(category, expected.category, "category is correct"); | ||
is(method, expected.method, "method is correct"); | ||
is(object, expected.object, "object is correct"); | ||
is(value, expected.value, "value is correct"); | ||
|
||
// extras | ||
is(extra.host, expected.extra.host, "host is correct"); | ||
ok(extra.width > 0, "width is greater than 0"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
devtools/client/responsive.html/test/browser/browser_telemetry_activate_rdm.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* Any copyright is dedicated to the Public Domain. | ||
* http://creativecommons.org/publicdomain/zero/1.0/ */ | ||
|
||
"use strict"; | ||
const URL = | ||
"data:text/html;charset=utf8,browser_telemetry_activate_rdm.js"; | ||
const OPTOUT = Ci.nsITelemetry.DATASET_RELEASE_CHANNEL_OPTOUT; | ||
const DATA = [ | ||
{ | ||
timestamp: null, | ||
category: "devtools.main", | ||
method: "activate", | ||
object: "responsive_design", | ||
value: null, | ||
extra: { | ||
host: "none", | ||
width: "1300" | ||
} | ||
}, { | ||
timestamp: null, | ||
category: "devtools.main", | ||
method: "activate", | ||
object: "responsive_design", | ||
value: null, | ||
extra: { | ||
host: "bottom", | ||
width: "1300" | ||
} | ||
} | ||
]; | ||
|
||
add_task(async function() { | ||
// Let's reset the counts. | ||
Services.telemetry.clearEvents(); | ||
|
||
// Ensure no events have been logged | ||
const snapshot = Services.telemetry.snapshotEvents(OPTOUT, true); | ||
ok(!snapshot.parent, "No events have been logged for the main process"); | ||
|
||
const tab = await addTab(URL); | ||
const target = TargetFactory.forTab(tab); | ||
|
||
await openCloseRDM(tab); | ||
await gDevTools.showToolbox(target, "inspector"); | ||
await openCloseRDM(tab); | ||
await checkResults(); | ||
}); | ||
|
||
async function openCloseRDM(tab) { | ||
let { ui } = await openRDM(tab); | ||
let clientClosed = waitForClientClose(ui); | ||
|
||
closeRDM(tab, { | ||
reason: "TabClose", | ||
}); | ||
|
||
// This flag is set at the end of `ResponsiveUI.destroy`. If it is true | ||
// without waiting for `closeRDM` above, then we must have closed | ||
// synchronously. | ||
is(ui.destroyed, true, "RDM closed synchronously"); | ||
|
||
await clientClosed; | ||
} | ||
|
||
async function checkResults() { | ||
const snapshot = Services.telemetry.snapshotEvents(OPTOUT, true); | ||
const events = snapshot.parent.filter(event => event[1] === "devtools.main" && | ||
event[2] === "activate" && | ||
event[4] === null | ||
); | ||
|
||
for (let i in events) { | ||
const [ timestamp, category, method, object, value, extra ] = events[i]; | ||
|
||
const expected = DATA[i]; | ||
|
||
// ignore timestamp | ||
ok(timestamp > 0, "timestamp is greater than 0"); | ||
is(category, expected.category, "category is correct"); | ||
is(method, expected.method, "method is correct"); | ||
is(object, expected.object, "object is correct"); | ||
is(value, expected.value, "value is correct"); | ||
|
||
// extras | ||
is(extra.host, expected.extra.host, "host is correct"); | ||
ok(extra.width > 0, "width is greater than 0"); | ||
} | ||
} |