haikuwebkit/LayoutTests/system-preview/detection.html

123 lines
2.9 KiB
HTML
Raw Permalink Normal View History

<!DOCTYPE html>
<script>
if (window.testRunner)
window.testRunner.dumpAsText();
function getSystemPreviewData(id)
{
const container = document.getElementById(id);
const link = container.querySelector("a");
let children = [];
if (link)
children = link.children;
const result = container.querySelectorAll("p")[1];
return [link, children, result];
}
function addResult(resultElement, txt)
{
resultElement.textContent += txt;
}
const TESTS = ["valid-1", "valid-2", "valid-3", "invalid-1", "invalid-2", "invalid-3", "invalid-4", "invalid-5"];
window.addEventListener("load", () => {
if (!window.internals)
return;
TESTS.forEach(id => {
const [link, children, result] = getSystemPreviewData(id);
if (link) {
addResult(result, "Link element present.");
if (internals.isSystemPreviewLink(link))
addResult(result, " Identified as system preview.");
else
addResult(result, " Not identified as system preview.");
} else
addResult(result, "No link.");
if (children && children.length > 0) {
for (let i = 0; i < children.length; i++) {
if (internals.isSystemPreviewImage(children[i]))
addResult(result, ` Child ${i} is an image inside a system preview.`);
else
addResult(result, ` Child ${i} is not an image inside a system preview.`);
}
}
// Specific test for the case that is just an image.
if (id == "invalid-5") {
const child = document.getElementById(id).children[0];
if (internals.isSystemPreviewImage(child))
addResult(result, ` Child is an image inside a system preview.`);
else
addResult(result, ` Child is not an image inside a system preview.`);
}
});
}, false);
</script>
<p>This test only works in WKTR or DRT.</p>
<div id="valid-1">
<p>Valid system preview</p>
Move SystemPreview code from WebKitAdditions to WebKit https://bugs.webkit.org/show_bug.cgi?id=189252 <rdar://problem/44080245> Reviewed by Wenson Hsieh. Source/WebCore: Move the WebKitAdditions code into WebKit/WebCore. * html/HTMLAnchorElement.cpp: (WebCore::HTMLAnchorElement::relList const): Look for "ar". (WebCore::HTMLAnchorElement::isSystemPreviewLink const): Ditto. * platform/MIMETypeRegistry.cpp: Add a couple of new static methods for System Preview MIME types. (WebCore::initializeSystemPreviewMIMETypes): (WebCore::MIMETypeRegistry::getSystemPreviewMIMETypes): (WebCore::MIMETypeRegistry::isSystemPreviewMIMEType): * platform/MIMETypeRegistry.h: * rendering/RenderThemeIOS.mm: Load the ARKit artwork from the framework. (WebCore::arKitBundle): (WebCore::loadARKitPDFPage): (WebCore::systemPreviewLogo): (WebCore::RenderThemeIOS::paintSystemPreviewBadge): * testing/Internals.cpp: Remove internal helper. (WebCore::Internals::systemPreviewRelType): Deleted. * testing/Internals.h: * testing/Internals.idl: Source/WebKit: Move the WebKitAdditions code into WebKit/WebCore. * UIProcess/Cocoa/SystemPreviewControllerCocoa.mm: (getUTIForMIMEType): Helper to get the system UTI for USDZ files. (-[_WKPreviewControllerDataSource previewController:previewItemAtIndex:]): * UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm: Use the new methods in MIMETypeRegistry. (-[WKWebViewContentProviderRegistry initWithConfiguration:]): * UIProcess/SystemPreviewController.cpp: Ditto. (WebKit::SystemPreviewController::canPreview const): * UIProcess/ios/WKSystemPreviewView.mm: (getUTIForMIMEType): Similar helper to above. (-[WKSystemPreviewView web_setContentProviderData:suggestedFilename:]): LayoutTests: This test no longer needs an internal helper. * system-preview/detection.html: Canonical link: https://commits.webkit.org/204265@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235626 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-04 19:38:33 +00:00
<a href="/" rel="ar">
<img>
</a>
<p>Result: </p>
</div>
<div id="valid-2">
<p>Valid system preview (multiple rel values)</p>
Move SystemPreview code from WebKitAdditions to WebKit https://bugs.webkit.org/show_bug.cgi?id=189252 <rdar://problem/44080245> Reviewed by Wenson Hsieh. Source/WebCore: Move the WebKitAdditions code into WebKit/WebCore. * html/HTMLAnchorElement.cpp: (WebCore::HTMLAnchorElement::relList const): Look for "ar". (WebCore::HTMLAnchorElement::isSystemPreviewLink const): Ditto. * platform/MIMETypeRegistry.cpp: Add a couple of new static methods for System Preview MIME types. (WebCore::initializeSystemPreviewMIMETypes): (WebCore::MIMETypeRegistry::getSystemPreviewMIMETypes): (WebCore::MIMETypeRegistry::isSystemPreviewMIMEType): * platform/MIMETypeRegistry.h: * rendering/RenderThemeIOS.mm: Load the ARKit artwork from the framework. (WebCore::arKitBundle): (WebCore::loadARKitPDFPage): (WebCore::systemPreviewLogo): (WebCore::RenderThemeIOS::paintSystemPreviewBadge): * testing/Internals.cpp: Remove internal helper. (WebCore::Internals::systemPreviewRelType): Deleted. * testing/Internals.h: * testing/Internals.idl: Source/WebKit: Move the WebKitAdditions code into WebKit/WebCore. * UIProcess/Cocoa/SystemPreviewControllerCocoa.mm: (getUTIForMIMEType): Helper to get the system UTI for USDZ files. (-[_WKPreviewControllerDataSource previewController:previewItemAtIndex:]): * UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm: Use the new methods in MIMETypeRegistry. (-[WKWebViewContentProviderRegistry initWithConfiguration:]): * UIProcess/SystemPreviewController.cpp: Ditto. (WebKit::SystemPreviewController::canPreview const): * UIProcess/ios/WKSystemPreviewView.mm: (getUTIForMIMEType): Similar helper to above. (-[WKSystemPreviewView web_setContentProviderData:suggestedFilename:]): LayoutTests: This test no longer needs an internal helper. * system-preview/detection.html: Canonical link: https://commits.webkit.org/204265@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235626 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-04 19:38:33 +00:00
<a href="/" rel="foo ar">
<img>
</a>
<p>Result: </p>
</div>
<div id="valid-3">
<p>Valid system preview (picture child)</p>
Move SystemPreview code from WebKitAdditions to WebKit https://bugs.webkit.org/show_bug.cgi?id=189252 <rdar://problem/44080245> Reviewed by Wenson Hsieh. Source/WebCore: Move the WebKitAdditions code into WebKit/WebCore. * html/HTMLAnchorElement.cpp: (WebCore::HTMLAnchorElement::relList const): Look for "ar". (WebCore::HTMLAnchorElement::isSystemPreviewLink const): Ditto. * platform/MIMETypeRegistry.cpp: Add a couple of new static methods for System Preview MIME types. (WebCore::initializeSystemPreviewMIMETypes): (WebCore::MIMETypeRegistry::getSystemPreviewMIMETypes): (WebCore::MIMETypeRegistry::isSystemPreviewMIMEType): * platform/MIMETypeRegistry.h: * rendering/RenderThemeIOS.mm: Load the ARKit artwork from the framework. (WebCore::arKitBundle): (WebCore::loadARKitPDFPage): (WebCore::systemPreviewLogo): (WebCore::RenderThemeIOS::paintSystemPreviewBadge): * testing/Internals.cpp: Remove internal helper. (WebCore::Internals::systemPreviewRelType): Deleted. * testing/Internals.h: * testing/Internals.idl: Source/WebKit: Move the WebKitAdditions code into WebKit/WebCore. * UIProcess/Cocoa/SystemPreviewControllerCocoa.mm: (getUTIForMIMEType): Helper to get the system UTI for USDZ files. (-[_WKPreviewControllerDataSource previewController:previewItemAtIndex:]): * UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm: Use the new methods in MIMETypeRegistry. (-[WKWebViewContentProviderRegistry initWithConfiguration:]): * UIProcess/SystemPreviewController.cpp: Ditto. (WebKit::SystemPreviewController::canPreview const): * UIProcess/ios/WKSystemPreviewView.mm: (getUTIForMIMEType): Similar helper to above. (-[WKSystemPreviewView web_setContentProviderData:suggestedFilename:]): LayoutTests: This test no longer needs an internal helper. * system-preview/detection.html: Canonical link: https://commits.webkit.org/204265@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235626 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-04 19:38:33 +00:00
<a href="/" rel="ar">
<picture></picture>
</a>
<p>Result: </p>
</div>
<div id="invalid-1">
<p>Invalid system preview (wrong rel value)</p>
Move SystemPreview code from WebKitAdditions to WebKit https://bugs.webkit.org/show_bug.cgi?id=189252 <rdar://problem/44080245> Reviewed by Wenson Hsieh. Source/WebCore: Move the WebKitAdditions code into WebKit/WebCore. * html/HTMLAnchorElement.cpp: (WebCore::HTMLAnchorElement::relList const): Look for "ar". (WebCore::HTMLAnchorElement::isSystemPreviewLink const): Ditto. * platform/MIMETypeRegistry.cpp: Add a couple of new static methods for System Preview MIME types. (WebCore::initializeSystemPreviewMIMETypes): (WebCore::MIMETypeRegistry::getSystemPreviewMIMETypes): (WebCore::MIMETypeRegistry::isSystemPreviewMIMEType): * platform/MIMETypeRegistry.h: * rendering/RenderThemeIOS.mm: Load the ARKit artwork from the framework. (WebCore::arKitBundle): (WebCore::loadARKitPDFPage): (WebCore::systemPreviewLogo): (WebCore::RenderThemeIOS::paintSystemPreviewBadge): * testing/Internals.cpp: Remove internal helper. (WebCore::Internals::systemPreviewRelType): Deleted. * testing/Internals.h: * testing/Internals.idl: Source/WebKit: Move the WebKitAdditions code into WebKit/WebCore. * UIProcess/Cocoa/SystemPreviewControllerCocoa.mm: (getUTIForMIMEType): Helper to get the system UTI for USDZ files. (-[_WKPreviewControllerDataSource previewController:previewItemAtIndex:]): * UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm: Use the new methods in MIMETypeRegistry. (-[WKWebViewContentProviderRegistry initWithConfiguration:]): * UIProcess/SystemPreviewController.cpp: Ditto. (WebKit::SystemPreviewController::canPreview const): * UIProcess/ios/WKSystemPreviewView.mm: (getUTIForMIMEType): Similar helper to above. (-[WKSystemPreviewView web_setContentProviderData:suggestedFilename:]): LayoutTests: This test no longer needs an internal helper. * system-preview/detection.html: Canonical link: https://commits.webkit.org/204265@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235626 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-04 19:38:33 +00:00
<a href="/" rel="arfoo">
<img>
</a>
<p>Result: </p>
</div>
<div id="invalid-2">
<p>Invalid system preview (wrong children)</p>
Move SystemPreview code from WebKitAdditions to WebKit https://bugs.webkit.org/show_bug.cgi?id=189252 <rdar://problem/44080245> Reviewed by Wenson Hsieh. Source/WebCore: Move the WebKitAdditions code into WebKit/WebCore. * html/HTMLAnchorElement.cpp: (WebCore::HTMLAnchorElement::relList const): Look for "ar". (WebCore::HTMLAnchorElement::isSystemPreviewLink const): Ditto. * platform/MIMETypeRegistry.cpp: Add a couple of new static methods for System Preview MIME types. (WebCore::initializeSystemPreviewMIMETypes): (WebCore::MIMETypeRegistry::getSystemPreviewMIMETypes): (WebCore::MIMETypeRegistry::isSystemPreviewMIMEType): * platform/MIMETypeRegistry.h: * rendering/RenderThemeIOS.mm: Load the ARKit artwork from the framework. (WebCore::arKitBundle): (WebCore::loadARKitPDFPage): (WebCore::systemPreviewLogo): (WebCore::RenderThemeIOS::paintSystemPreviewBadge): * testing/Internals.cpp: Remove internal helper. (WebCore::Internals::systemPreviewRelType): Deleted. * testing/Internals.h: * testing/Internals.idl: Source/WebKit: Move the WebKitAdditions code into WebKit/WebCore. * UIProcess/Cocoa/SystemPreviewControllerCocoa.mm: (getUTIForMIMEType): Helper to get the system UTI for USDZ files. (-[_WKPreviewControllerDataSource previewController:previewItemAtIndex:]): * UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm: Use the new methods in MIMETypeRegistry. (-[WKWebViewContentProviderRegistry initWithConfiguration:]): * UIProcess/SystemPreviewController.cpp: Ditto. (WebKit::SystemPreviewController::canPreview const): * UIProcess/ios/WKSystemPreviewView.mm: (getUTIForMIMEType): Similar helper to above. (-[WKSystemPreviewView web_setContentProviderData:suggestedFilename:]): LayoutTests: This test no longer needs an internal helper. * system-preview/detection.html: Canonical link: https://commits.webkit.org/204265@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235626 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-04 19:38:33 +00:00
<a href="/" rel="ar">
<span>hello</span>
</a>
<p>Result: </p>
</div>
<div id="invalid-3">
<p>Invalid system preview (too many children)</p>
Move SystemPreview code from WebKitAdditions to WebKit https://bugs.webkit.org/show_bug.cgi?id=189252 <rdar://problem/44080245> Reviewed by Wenson Hsieh. Source/WebCore: Move the WebKitAdditions code into WebKit/WebCore. * html/HTMLAnchorElement.cpp: (WebCore::HTMLAnchorElement::relList const): Look for "ar". (WebCore::HTMLAnchorElement::isSystemPreviewLink const): Ditto. * platform/MIMETypeRegistry.cpp: Add a couple of new static methods for System Preview MIME types. (WebCore::initializeSystemPreviewMIMETypes): (WebCore::MIMETypeRegistry::getSystemPreviewMIMETypes): (WebCore::MIMETypeRegistry::isSystemPreviewMIMEType): * platform/MIMETypeRegistry.h: * rendering/RenderThemeIOS.mm: Load the ARKit artwork from the framework. (WebCore::arKitBundle): (WebCore::loadARKitPDFPage): (WebCore::systemPreviewLogo): (WebCore::RenderThemeIOS::paintSystemPreviewBadge): * testing/Internals.cpp: Remove internal helper. (WebCore::Internals::systemPreviewRelType): Deleted. * testing/Internals.h: * testing/Internals.idl: Source/WebKit: Move the WebKitAdditions code into WebKit/WebCore. * UIProcess/Cocoa/SystemPreviewControllerCocoa.mm: (getUTIForMIMEType): Helper to get the system UTI for USDZ files. (-[_WKPreviewControllerDataSource previewController:previewItemAtIndex:]): * UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm: Use the new methods in MIMETypeRegistry. (-[WKWebViewContentProviderRegistry initWithConfiguration:]): * UIProcess/SystemPreviewController.cpp: Ditto. (WebKit::SystemPreviewController::canPreview const): * UIProcess/ios/WKSystemPreviewView.mm: (getUTIForMIMEType): Similar helper to above. (-[WKSystemPreviewView web_setContentProviderData:suggestedFilename:]): LayoutTests: This test no longer needs an internal helper. * system-preview/detection.html: Canonical link: https://commits.webkit.org/204265@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235626 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-04 19:38:33 +00:00
<a href="/" rel="ar">
<span>hello</span>
<img>
</a>
<p>Result: </p>
</div>
<div id="invalid-4">
<p>Invalid system preview (no children)</p>
Move SystemPreview code from WebKitAdditions to WebKit https://bugs.webkit.org/show_bug.cgi?id=189252 <rdar://problem/44080245> Reviewed by Wenson Hsieh. Source/WebCore: Move the WebKitAdditions code into WebKit/WebCore. * html/HTMLAnchorElement.cpp: (WebCore::HTMLAnchorElement::relList const): Look for "ar". (WebCore::HTMLAnchorElement::isSystemPreviewLink const): Ditto. * platform/MIMETypeRegistry.cpp: Add a couple of new static methods for System Preview MIME types. (WebCore::initializeSystemPreviewMIMETypes): (WebCore::MIMETypeRegistry::getSystemPreviewMIMETypes): (WebCore::MIMETypeRegistry::isSystemPreviewMIMEType): * platform/MIMETypeRegistry.h: * rendering/RenderThemeIOS.mm: Load the ARKit artwork from the framework. (WebCore::arKitBundle): (WebCore::loadARKitPDFPage): (WebCore::systemPreviewLogo): (WebCore::RenderThemeIOS::paintSystemPreviewBadge): * testing/Internals.cpp: Remove internal helper. (WebCore::Internals::systemPreviewRelType): Deleted. * testing/Internals.h: * testing/Internals.idl: Source/WebKit: Move the WebKitAdditions code into WebKit/WebCore. * UIProcess/Cocoa/SystemPreviewControllerCocoa.mm: (getUTIForMIMEType): Helper to get the system UTI for USDZ files. (-[_WKPreviewControllerDataSource previewController:previewItemAtIndex:]): * UIProcess/Cocoa/WKWebViewContentProviderRegistry.mm: Use the new methods in MIMETypeRegistry. (-[WKWebViewContentProviderRegistry initWithConfiguration:]): * UIProcess/SystemPreviewController.cpp: Ditto. (WebKit::SystemPreviewController::canPreview const): * UIProcess/ios/WKSystemPreviewView.mm: (getUTIForMIMEType): Similar helper to above. (-[WKSystemPreviewView web_setContentProviderData:suggestedFilename:]): LayoutTests: This test no longer needs an internal helper. * system-preview/detection.html: Canonical link: https://commits.webkit.org/204265@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@235626 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-04 19:38:33 +00:00
<a href="/" rel="ar">
</a>
<p>Result: </p>
</div>
<div id="invalid-5">
<p>Invalid system preview (just an image)</p>
<img>
<p>Result: </p>
</div>