Skip to content

Commit

Permalink
Remove the never-launched manifest frontend code
Browse files Browse the repository at this point in the history
The use of the manifest in the frontend never shipped, and the flags are
off in prod and staging. This code is non-trivial and removing it makes
the code easier to understand.

The /api/manifest endpoint is not removed because it is still used by
Bikeshed[0].

[0]: https://github.com/tabatkins/bikeshed/blob/e797b9548c0bd140c9b1500809869b09f50f7d99/bikeshed/update/updateWpt.py

Updates #56
  • Loading branch information
stephenmcgruer committed Mar 10, 2021
1 parent b6f7694 commit 2c7cd2a
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 236 deletions.
10 changes: 1 addition & 9 deletions webapp/components/test-file-results.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,7 @@ class TestFileResults extends WPTFlags(LoadingState(PathInfo(
if (!response.ok) {
return null;
}
if (!this.reftestAnalyzerMockScreenshots) {
return response.json();
}
// Use some arbitrary screenshots for any without them.
const screenshots = {};
screenshots[this.path] = 'sha1:000c495e8f587dac40894d0cacb5a7ca769410c6';
screenshots[this.path.replace(/.html$/, '-ref.html')] = 'sha1:000c495e8f587dac40894d0cacb5a7ca769410c6';
return response.json()
.then(r => Object.assign({ screenshots }, r));
return response.json();
}

resultsTableHeaders(resultsPerTestRun) {
Expand Down
30 changes: 0 additions & 30 deletions webapp/components/wpt-flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ Object.defineProperty(wpt, 'ClientSideFeatures', {
'colorHomepage',
'diffFromAPI',
'displayMetadata',
'fetchManifestForTestList',
'githubCommitLinks',
'githubLogin',
'interopScoreColumn',
Expand All @@ -49,12 +48,8 @@ Object.defineProperty(wpt, 'ClientSideFeatures', {
'queryBuilder',
'queryBuilderSHA',
'reftestAnalyzer',
'reftestAnalyzerMockScreenshots',
'reftestIframes',
'searchCacheInterop',
'showBSF',
'showTestType',
'showTestRefURL',
'structuredQueries',
'searchPRsForDirectories',
'triageMetadataUI',
Expand Down Expand Up @@ -232,31 +227,6 @@ class WPTFlagsEditor extends FlagsEditorClass(/*environmentFlags*/ false) {
Compute interop results the fly, using the searchcache
</paper-checkbox>
</paper-item>
<paper-item>
<paper-checkbox checked="{{fetchManifestForTestList}}">
Fetch a manifest for a complete (expected) list of tests.
</paper-checkbox>
</paper-item>
<paper-item sub-item>
<paper-checkbox checked="{{showTestType}}">
Display test types
</paper-checkbox>
</paper-item>
<paper-item sub-item>
<paper-checkbox checked="{{showTestRefURL}}">
Display link to ref (for reftests)
</paper-checkbox>
</paper-item>
<paper-item sub-item>
<paper-checkbox checked="{{reftestIframes}}">
Display comparitive iframes for reftests
</paper-checkbox>
</paper-item>
<paper-item sub-item>
<paper-checkbox checked="{{reftestAnalyzerMockScreenshots}}">
Use mock screenshots for all the reftests
</paper-checkbox>
</paper-item>
<paper-item>
<paper-checkbox checked="{{reftestAnalyzer}}">
Show the reftest analyzer for reftests
Expand Down
198 changes: 1 addition & 197 deletions webapp/views/wpt-results.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,6 @@ class WPTResults extends AmendMetadataMixin(Pluralizer(WPTColors(WPTFlags(PathIn
border-radius: 4px;
background-color: var(--paper-blue-100);
}
.test-type-icon {
padding: 0;
}
.test-type-icon iron-icon {
height: 16px;
width: 16px;
}
@media (max-width: 1200px) {
table tr td:first-child::after {
Expand All @@ -142,16 +135,6 @@ class WPTResults extends AmendMetadataMixin(Pluralizer(WPTColors(WPTFlags(PathIn
}
}
.compare {
display: flex;
}
.compare .column {
flex-grow: 1;
}
.compare .column iframe {
width: 100%;
height: 600px;
}
.view-triage {
margin-left: 30px;
}
Expand Down Expand Up @@ -219,13 +202,6 @@ class WPTResults extends AmendMetadataMixin(Pluralizer(WPTColors(WPTFlags(PathIn
<template is="dom-repeat" items="{{displayedNodes}}" as="node">
<tr>
<td class="test-type-icon">
<template is="dom-if" if="{{showTestType}}">
<template is="dom-if" if="{{node.testTypeIcon}}">
<iron-icon icon="{{node.testTypeIcon}}" title="[[node.testType]] test"></iron-icon>
</template>
</template>
</td>
<td onclick="[[handleTriageSelect(null, node, testRun)]]" onmouseover="[[handleTriageHover(null, node, testRun)]]">
<path-part prefix="/results" path="{{ node.path }}" query="{{ query }}" is-dir="{{ node.isDir }}"></path-part>
<template is="dom-if" if="[[shouldDisplayMetadata(null, node.path, metadataMap)]]">
Expand Down Expand Up @@ -308,29 +284,6 @@ class WPTResults extends AmendMetadataMixin(Pluralizer(WPTColors(WPTFlags(PathIn
</div>
</template>
<template is="dom-if" if="[[isRefTest]]">
<template is="dom-if" if="[[ reftestIframes ]]">
<div class="separator"></div>
<section>
<h4>[[path]] in this browser</h4>
<div class="compare">
<div class="column">
<h5>Result</h5>
<template is="dom-if" if="[[testURL]]">
<iframe src="[[https(testURL)]]"></iframe>
</template>
</div>
<div class="column">
<h5>Reference</h5>
<template is="dom-if" if="[[testRefURL]]">
<iframe src="[[https(testRefURL)]]"></iframe>
</template>
</div>
</div>
</section>
</template>
</template>
<template is="dom-if" if="[[displayMetadata]]">
<wpt-metadata products="[[displayedProducts]]"
path="[[path]]"
Expand All @@ -356,27 +309,6 @@ class WPTResults extends AmendMetadataMixin(Pluralizer(WPTColors(WPTFlags(PathIn
type: Boolean,
computed: 'computePathIsASubfolderOrFile(pathIsASubfolder, pathIsATestFile)'
},
sourcePath: {
type: String,
computed: 'computeSourcePath(path, manifest)',
},
testType: {
type: String,
computed: 'computeTestType(path, manifest)',
value: '',
},
isRefTest: {
type: Boolean,
computed: 'computeIsRefTest(testType)'
},
testURL: {
type: String,
computed: 'computeTestURL(testType, path)',
},
testRefURL: {
type: String,
computed: 'computeTestRefURL(testType, path, manifest)',
},
liveTestDomain: {
type: String,
computed: 'computeLiveTestDomain()',
Expand Down Expand Up @@ -423,7 +355,6 @@ class WPTResults extends AmendMetadataMixin(Pluralizer(WPTColors(WPTFlags(PathIn
},
onlyShowDifferences: Boolean,
// path => {type, file[, refPath]} simplification.
manifest: Object,
screenshots: Array,
};
}
Expand All @@ -443,63 +374,13 @@ class WPTResults extends AmendMetadataMixin(Pluralizer(WPTColors(WPTFlags(PathIn
return isSubfolder || isFile;
}

computeSourcePath(path, manifest) {
if (!this.computePathIsATestFile(path) || !manifest) {
return path;
}
const metadata = manifest.get(path);
if (metadata) {
return metadata.file;
}
}

computeIsRefTest(testType) {
return testType === 'reftest';
}

computeTestURL(testType, path) {
if (testType === 'wdspec') {
return;
}
return new URL(`${this.scheme}://${this.liveTestDomain}${path}`);
}

computeTestRefURL(testType, path, manifest) {
if (!this.showTestRefURL || testType !== 'reftest') {
return;
}
const metadata = manifest.get(path);
if (metadata && metadata.refPath) {
return this.computeTestURL(testType, metadata.refPath);
}
}

computeLiveTestDomain() {
if (this.webPlatformTestsLive) {
return 'wpt.live';
}
return 'w3c-test.org';
}

https(url) {
return `${url}`.replace(/^http:/, 'https:');
}

computeTestType(path, manifest) {
if (!this.computePathIsATestFile(path) || !manifest) {
return;
}
const metadata = manifest.get(path);
return metadata && metadata.type;
}

computeTestTypeIcon(testType) {
switch (testType) {
case 'manual': return 'touch-app';
case 'reftest': return 'image:compare';
}
}

computeTestPaths(searchResults) {
const paths = searchResults && searchResults.map(r => r.test) || [];
return new Set(paths);
Expand Down Expand Up @@ -555,13 +436,6 @@ class WPTResults extends AmendMetadataMixin(Pluralizer(WPTColors(WPTFlags(PathIn
};
this.fetchDiff();
}

// Load a manifest.
if (this.fetchManifestForTestList && runs && runs.length) {
const shas = new Set((runs || []).map(r => r.revision));
const sha = shas.size === 1 ? Array.from(shas)[0] : 'latest';
this.fetchManifestForSHA(sha);
}
}),
() => {
this.resultsLoadFailed = true;
Expand Down Expand Up @@ -665,60 +539,6 @@ class WPTResults extends AmendMetadataMixin(Pluralizer(WPTColors(WPTFlags(PathIn
);
}

fetchManifestForSHA(sha) {
const url = new URL('/api/manifest', window.location);
const isSpecificSHA = sha && !this.computeIsLatest(sha);
if (isSpecificSHA) {
url.searchParams.set('sha', sha);
}
this.load(
fetch(url).then(
async r => {
if (!r.ok) {
// eslint-disable-next-line no-console
console.warn(`Failed to load manifest for ${sha}: ${r.status} - ${r.statusText}`);
// Fall back to the latest manifest if we 404 for a specific SHA.
return r.status === 404
&& isSpecificSHA
&& this.fetchManifestForSHA('latest');
}
let manifestJSON = await r.json();
const manifest = new Map();
manifest.sha = sha || r.headers && r.headers['X-WPT-SHA'];
for (const [type, items] of Object.entries(manifestJSON.items)) {
if (!TEST_TYPES.includes(type)) {
continue;
}
for (const [file, tests] of Object.entries(items)) {
for (const test of tests) {
const metadata = {
file,
type,
};
if (type === 'reftest') {
metadata.refPath = test[1][0][0];
}
// Ensure leading slashes (e.g. manual/visual tests don't).
if (!metadata.file.startsWith('/')) {
metadata.file = `/${file}`;
}
let path = test[0];
if (!path.startsWith('/')) {
path = `/${path}`;
}
manifest.set(path, metadata);
}
}
}
this.manifest = manifest;
// eslint-disable-next-line no-console
console.info(`Loaded manifest ${manifest.sha}`);
this.refreshDisplayedNodes();
}
)
);
}

pathUpdated(path) {
this.refreshDisplayedNodes();
}
Expand Down Expand Up @@ -757,25 +577,9 @@ class WPTResults extends AmendMetadataMixin(Pluralizer(WPTColors(WPTFlags(PathIn
})),
};
}
if (this.computePathIsATestFile(name)) {
nodes[name].testType = this.computeTestType(testPath, this.manifest);
nodes[name].testTypeIcon = this.computeTestTypeIcon(nodes[name].testType);
}
return name;
};

// Add an empty row for all the tests known from the manifest.
const knownNodes = {};
if (this.manifest && !this.search) {
for (const [path, { type }] of Object.entries(this.manifest)) {
if (TEST_TYPES.includes(type)) {
if (path.startsWith(prefix)) {
collapsePathOnto(path, knownNodes);
}
}
}
}

const resultsByPath = this.searchResults
// Filter out files not in this directory.
.filter(r => r.test.startsWith(prefix))
Expand Down Expand Up @@ -836,7 +640,7 @@ class WPTResults extends AmendMetadataMixin(Pluralizer(WPTColors(WPTFlags(PathIn
}
}
return nodes;
}, knownNodes);
}, {});
this.displayedNodes = Object.values(resultsByPath)
.filter(row => {
if (!this.onlyShowDifferences) {
Expand Down

0 comments on commit 2c7cd2a

Please sign in to comment.