Skip to content

Commit

Permalink
Add Firefox support
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Stein <[email protected]>
  • Loading branch information
texodus committed Oct 31, 2024
1 parent b5b3d7b commit 927dabe
Show file tree
Hide file tree
Showing 11 changed files with 89 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export function getDataValues(data, settings) {
value: toValue(main.type, data.mainValues[i]),
}));
}

return settings.mainValues.map((main) => ({
name: main.name,
value: toValue(
Expand All @@ -76,6 +77,7 @@ export function getDataValues(data, settings) {
),
}));
}

return [
{
name: settings.mainValues[0].name,
Expand Down
6 changes: 5 additions & 1 deletion packages/perspective-viewer-d3fc/test/js/splitby.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ test.describe("Tooltip data values with various 'Split By' configurations", () =
expect(tooltip_row_id_value).toBeTruthy();
expect(tooltip_row_id_value).toMatch(/^(?!NaN$|-$).+$/);
});

test("Show valid tooltip data with one 'Split By' configuration", async ({
page,
}) => {
Expand All @@ -78,8 +79,8 @@ test.describe("Tooltip data values with various 'Split By' configurations", () =
force: true,
}
);
await page.waitForSelector("#tooltip-values > li:nth-child(2)");

await page.waitForSelector("#tooltip-values > li:nth-child(2)");
let tooltip_row_id_value = await page.evaluate(async () => {
return document
.querySelector("perspective-viewer-d3fc-xyline")
Expand All @@ -88,9 +89,12 @@ test.describe("Tooltip data values with various 'Split By' configurations", () =
)?.textContent;
});

await page.pause();

expect(tooltip_row_id_value).toBeTruthy();
expect(tooltip_row_id_value).toMatch(/^(?!NaN$|-$).+$/);
});

test("Show valid tooltip data with multiple 'Split By' configuration", async ({
page,
}) => {
Expand Down
18 changes: 8 additions & 10 deletions packages/perspective-viewer-datagrid/test/js/column_style.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,10 @@ async function test_column(page, selector, selector2) {
window.__events__.push(evt);
});

const header_button = viewer
.querySelector("perspective-viewer-datagrid")
.shadowRoot.querySelector(
"regular-table thead tr:last-child th" + selector
);
const elem = viewer.querySelector("perspective-viewer-datagrid");
const header_button = (
window.chrome ? elem.shadowRoot : elem
).querySelector("regular-table thead tr:last-child th" + selector);

const rect = header_button.getBoundingClientRect();
return {
Expand Down Expand Up @@ -87,11 +86,10 @@ test.describe("Column Style Tests", () => {
);

// Find the column config menu button
const header_button = viewer
.querySelector("perspective-viewer-datagrid")
.shadowRoot.querySelector(
"regular-table thead tr:last-child th"
);
const elem = viewer.querySelector("perspective-viewer-datagrid");
const header_button = (
window.chrome ? elem.shadowRoot : elem
).querySelector("regular-table thead tr:last-child th");

// Get the button coords (slightly lower than center
// because of the location of the menu button within
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ async function getDatagridContents(page) {
if (!datagrid) {
return "MISSING DATAGRID";
}
const regularTable = datagrid.shadowRoot.querySelector("regular-table");
const regularTable = (
window.chrome ? datagrid.shadowRoot : datagrid
).querySelector("regular-table");
return regularTable?.innerHTML || "MISSING";
});
}
Expand Down
4 changes: 4 additions & 0 deletions rust/perspective-viewer/src/less/containers/scroll-panel.less
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,9 @@

.scroll-panel-content {
position: relative;

// firefox doesn't support zero-sized containers;
width: 1px;
margin-left: -1px;
}
}
9 changes: 4 additions & 5 deletions rust/perspective-viewer/test/js/column_settings.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,10 @@ test.describe("Plugin Styles", () => {
});

await page.waitForFunction(() => {
return (
document
.querySelector("perspective-viewer-datagrid")
?.shadowRoot?.querySelectorAll("tbody tr").length! >= 1
);
const elem = document.querySelector("perspective-viewer-datagrid");
return (window as any).chrome
? elem?.shadowRoot?.querySelectorAll("tbody tr").length! >= 1
: elem?.querySelectorAll("tbody tr").length! >= 1;
});

await expect(view.columnSettingsSidebar.container).toBeVisible();
Expand Down
1 change: 1 addition & 0 deletions rust/perspective-viewer/test/js/expressions.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ test.describe("Expressions", () => {
await addExprButton.click();
await page.evaluate(openSidebarAndScrollToBottom);
let clicked = await addExprButton.getAttribute("class");

expect(clicked).toBe("dragdrop-hover");
});

Expand Down
68 changes: 46 additions & 22 deletions rust/perspective-viewer/test/js/leaks.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ test.beforeEach(async ({ page }) => {

test.describe("leaks", () => {
// This originally has a timeout of 120000
test("doesn't leak elements", async ({ page }) => {
test("doesn't leak elements", async ({ page, browserName }) => {
let viewer = await page.$("perspective-viewer");
await page.evaluate(async (viewer) => {
window.__TABLE__ = await viewer.getTable();
Expand All @@ -38,9 +38,12 @@ test.describe("leaks", () => {

// From a helpful blog
// https://media-codings.com/articles/automatically-detect-memory-leaks-with-puppeteer
await page.evaluate(() => window.gc());
const heap1 = await page.evaluate(
() => performance.memory.usedJSHeapSize
if (browserName !== "firefox") {
await page.evaluate(() => window.gc());
}

const heap1 = await page.evaluate(() =>
window.chrome ? performance.memory.usedJSHeapSize : 1
);

for (var i = 0; i < 500; i++) {
Expand All @@ -61,9 +64,12 @@ test.describe("leaks", () => {
// TODO this is very generous memory allowance suggests we
// leak ~0.1% per instance.
// TODO: Not yet sure how to access window.gc() in Playwright
await page.evaluate(() => window.gc());
const heap2 = await page.evaluate(
() => performance.memory.usedJSHeapSize
if (browserName !== "firefox") {
await page.evaluate(() => window.gc());
}

const heap2 = await page.evaluate(() =>
window.chrome ? performance.memory.usedJSHeapSize : 1
);

expect((heap2 - heap1) / heap1).toBeLessThan(1);
Expand All @@ -77,16 +83,22 @@ test.describe("leaks", () => {
await compareContentsToSnapshot(contents, ["does-not-leak.txt"]);
});

test("doesn't leak views when setting group by", async ({ page }) => {
test("doesn't leak views when setting group by", async ({
page,
browserName,
}) => {
let viewer = await page.$("perspective-viewer");
await page.evaluate(async (viewer) => {
window.__TABLE__ = await viewer.getTable();
await viewer.reset();
}, viewer);

await page.evaluate(() => window.gc());
const heap1 = await page.evaluate(
() => performance.memory.usedJSHeapSize
if (browserName !== "firefox") {
await page.evaluate(() => window.gc());
}

const heap1 = await page.evaluate(() =>
window.chrome ? performance.memory.usedJSHeapSize : 1
);

for (var i = 0; i < 500; i++) {
Expand All @@ -108,9 +120,12 @@ test.describe("leaks", () => {
}, viewer);
}

await page.evaluate(() => window.gc());
const heap2 = await page.evaluate(
() => performance.memory.usedJSHeapSize
if (browserName !== "firefox") {
await page.evaluate(() => window.gc());
}

const heap2 = await page.evaluate(() =>
window.chrome ? performance.memory.usedJSHeapSize : 1
);
expect((heap2 - heap1) / heap1).toBeLessThan(0.5);

Expand All @@ -125,16 +140,22 @@ test.describe("leaks", () => {
]);
});

test("doesn't leak views when setting filters", async ({ page }) => {
test("doesn't leak views when setting filters", async ({
page,
browserName,
}) => {
let viewer = await page.$("perspective-viewer");
await page.evaluate(async (viewer) => {
window.__TABLE__ = await viewer.getTable();
await viewer.reset();
}, viewer);

await page.evaluate(() => window.gc());
const heap1 = await page.evaluate(
() => performance.memory.usedJSHeapSize
if (browserName !== "firefox") {
await page.evaluate(() => window.gc());
}

const heap1 = await page.evaluate(() =>
window.chrome ? performance.memory.usedJSHeapSize : 1
);

for (var i = 0; i < 500; i++) {
Expand All @@ -146,12 +167,15 @@ test.describe("leaks", () => {
}, viewer);
}

await page.evaluate(() => window.gc());
const heap2 = await page.evaluate(
() => performance.memory.usedJSHeapSize
if (browserName !== "firefox") {
await page.evaluate(() => window.gc());
}

const heap2 = await page.evaluate(() =>
window.chrome ? performance.memory.usedJSHeapSize : 1
);
expect((heap2 - heap1) / heap1).toBeLessThan(0.5);

expect((heap2 - heap1) / heap1).toBeLessThan(0.5);
const contents = await page.evaluate(async (viewer) => {
await viewer.restore({
filter: [["Sales", "<", 10]],
Expand Down
18 changes: 13 additions & 5 deletions rust/perspective-viewer/test/js/settings.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ test.describe("Settings", () => {
test("load and restore with settings called at the same time does not throw", async ({
page,
consoleLogs,
browserName,
}) => {
const errors = [];
page.on("pageerror", async (msg) => {
Expand Down Expand Up @@ -107,18 +108,25 @@ test.describe("Settings", () => {
});

const contents = await get_contents(page);
expect(errors).toEqual([
"::Intentional Load Error",
expect(errors[0]).toContain(
"::Intentional Load Error"
// "RuntimeError::unreachable",
]);
);

// await page.pause();

consoleLogs.expectedLogs.push(
"error",
/Invalid config: Error: `restore\(\)` called before `load\(\)`.*/
browserName === "firefox"
? /Invalid config: Error.*/
: /Invalid config: Error: `restore\(\)` called before `load\(\)`.*/
);

consoleLogs.expectedLogs.push(
"error",
/Caught error: Error: `restore\(\)` called before `load\(\)`.*/
browserName === "firefox"
? /Caught error: Error.*/
: /Caught error: Error: `restore\(\)` called before `load\(\)`.*/
);
});
});
Expand Down
5 changes: 3 additions & 2 deletions tools/perspective-test/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ if (package_venn.include.length === 0) {
}

const DEVICE_OPTIONS = {
"Desktop Firefox": {},
"Desktop Chrome": {
launchOptions: {
args: [
Expand Down Expand Up @@ -199,9 +200,9 @@ const GLOBAL_TEARDOWN_PATH = __require.resolve(

// See https://playwright.dev/docs/test-configuration.
export default defineConfig({
timeout: 360_000,
timeout: 30_000,
expect: {
timeout: 360_000,
timeout: 30_000,
},
forbidOnly: !!process.env.CI,
retries: 0,
Expand Down
Binary file modified tools/perspective-test/results.tar.gz
Binary file not shown.

0 comments on commit 927dabe

Please sign in to comment.