haikuwebkit/LayoutTests/fast/images/image-orientation-none-canv...

108 lines
2.9 KiB
HTML
Raw Permalink Normal View History

<!DOCTYPE html>
<style>
div.container {
display: inline-block;
margin-right: 20px;
margin-bottom: 10px;
width: 100px;
vertical-align: top;
}
div.box {
width: 102px;
height: 52px;
}
canvas {
border: 1px solid black;
width: 100px;
height: 50px;
}
</style>
Refactor TestOptions code in WebKitTestRunner to make it easier to rationalize and extend https://bugs.webkit.org/show_bug.cgi?id=217390 Reviewed by Darin Adler. Refactors TestOptions code in WebKitTestRunner to make it clear how options coming in at different levels are treated and what precedence each has. The order is (from least to most): - Global features passed to WebKitTestRunner via the command line (e.g. --show-touches) - Hardcoded features based on the path of the test being run (hopefully we can remove all soon) - Hardcoded platform specific defaults (currently only used by macOS for useThreadedScrolling). - Features from the test headers within the test itself. - Finally, a second chance for more platform specific defaults (currenly only used the Cocoa ports for setting enableProcessSwapOnNavigation and enableProcessSwapOnWindowOpen based on NSUserDefaults.) To make this change work, and pave the way for future autogeneration of some of these test options, the TestOptions struct (now class) was overhauled. Instead of storing the state itself, TestOptions is now an immutable owner of a TestFeatures object. TestFeatures is a simple struct that contains maps of option keys to values and can be merged with other TestFeatures objects. TestOptions takes a TestFeatures at construction, and exposes getters for all keys, as well as defaults for when they are not in the maps. In future changes, I would like to remove many of these (the ones that correspond with WebKit preferences anyway) and have the keys and values automatically dealt with by WKPreferences. * WebKitTestRunner/Options.cpp: * WebKitTestRunner/Options.h: Switch to std::unordered_map for consistency and ease of conversion. * WebKitTestRunner/PlatformWebView.h: (WTR::PlatformWebView::viewSupportsOptions const): Update to call new TestOptions functions. * WebKitTestRunner/StringFunctions.h: (WTR::toWK): (WTR::toWTFString): Add conversions for std::string. * WebKitTestRunner/TestController.h: * WebKitTestRunner/TestController.cpp: (WTR::TestController::initialize): Replace some bools with a new global TestFeatures instance that forms the base of all TestFeatures merges. (WTR::TestController::generateContextConfiguration const): (WTR::TestController::generatePageConfiguration): (WTR::TestController::createWebViewWithOptions): (WTR::TestController::ensureViewSupportsOptionsForTest): (WTR::TestController::resetPreferencesToConsistentValues): (WTR::TestController::resetStateToConsistentValues): Update to call new TestOptions functions. (WTR::TestController::createTestURL): Expose as a static member function on TestController for use in other files. (WTR::TestController::testOptionsForTest const): Rework to be a sequence of TestFeatures merges. (WTR::TestController::updateWebViewSizeForTest): (WTR::TestController::updateWindowScaleForTest): Update to call new TestOptions functions. (WTR::createTestURL): Deleted. (WTR::parseBooleanTestHeaderValue): Deleted. (WTR::parseStringTestHeaderValueAsRelativePath): Deleted. (WTR::parseStringTestHeaderValueAsURL): Deleted. (WTR::updateTestOptionsFromTestHeader): Deleted. (WTR::TestController::platformAddTestOptions const): Deleted. Moved TestOptions parsing to TestOptions.cpp * WebKitTestRunner/TestInvocation.cpp: (WTR::TestInvocation::createTestSettingsDictionary): Update to call new TestOptions functions. * WebKitTestRunner/TestOptions.h: Reworks TestOptions to be an immutable owner of a TestFeatures struct, which is a set of maps that map feature string keys, to values of type bool, double, string or string vector. * WebKitTestRunner/TestOptions.cpp: (WTR::merge): Merges two TestFeatures objects. If both contain the same key, the 'additional' TestFeatures overrides the 'base' TestFeatures. (WTR::dumpFeatures): Helper to dump features to stderr, useful for debugging. (WTR::keyType): Helper for parser to know which value parser to use. (WTR::parseBooleanTestHeaderValue): (WTR::parseStringTestHeaderValueAsRelativePath): (WTR::parseStringTestHeaderValueAsURL): Value parsers moved from TestController.cpp (WTR::parseTestHeader): Header parser moved from TestController.cpp. Update to now return a TestFeatures object and use keyType to pick value parser rather than inlining the if statements. (WTR::hardcodedFeaturesBasedOnPathForTest): Moved from the TestOptions contructor and reworked to return a TestFeatures object to be merged by the caller. (WTR::featureDefaultsFromTestHeaderForTest): Creates a TestFeatures for the test headers of the current test. * WebKitTestRunner/cocoa/TestControllerCocoa.mm: (WTR::TestController::platformSpecificFeatureOverridesDefaultsForTest const): Reworked to now return a TestFeatures object that will be merged, rather than updating a TestOptions. Moves enableInAppBrowserPrivacy work to TestController::platformWillRunTest where it is more appropriate. (WTR::TestController::platformInitializeDataStore): (WTR::TestController::platformCreateWebView): (WTR::TestController::finishCreatingPlatformWebView): (WTR::TestController::setApplicationBundleIdentifier): (WTR::TestController::cocoaResetStateToConsistentValues): (WTR::contentMode): Update to call new TestOptions functions. * WebKitTestRunner/ios/TestControllerIOS.mm: (WTR::TestController::platformResetStateToConsistentValues): (WTR::TestController::platformConfigureViewForTest): Update to call new TestOptions functions. (WTR::TestController::platformSpecificFeatureDefaultsForTest const): (WTR::TestController::updatePlatformSpecificTestOptionsForTest const): Deleted. Moved GeneratedTouchesDebugWindow work to TestController::platformConfigureViewForTest where it is more appropriate and removed shouldShowTouches setting as that is done globally now. * WebKitTestRunner/mac/PlatformWebViewMac.mm: (WTR::PlatformWebView::PlatformWebView): Update to call new TestOptions functions. * WebKitTestRunner/mac/TestControllerMac.mm: (WTR::TestController::platformSpecificFeatureDefaultsForTest const): (WTR::TestController::updatePlatformSpecificTestOptionsForTest const): Deleted. Remove shouldUseRemoteLayerTree and shouldShowWebView, as those are now done globally, and re-implemented useThreadedScrolling to use boolFeatures. * WebKitTestRunner/win/TestControllerWin.cpp: (WTR::TestController::platformSpecificFeatureDefaultsForTest const): (WTR::TestController::updatePlatformSpecificTestOptionsForTest const): Deleted. Updated for new signature. * WebKitTestRunner/wpe/TestControllerWPE.cpp: (WTR::TestController::platformSpecificFeatureDefaultsForTest const): (WTR::TestController::updatePlatformSpecificTestOptionsForTest const): Deleted. Updated for new signature. * WebKitTestRunner/gtk/TestControllerGTK.cpp: (WTR::TestController::platformSpecificFeatureDefaultsForTest const): (WTR::TestController::updatePlatformSpecificTestOptionsForTest const): Deleted. Updated for new signature. Canonical link: https://commits.webkit.org/230271@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268238 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-10-09 00:45:29 +00:00
<script>
if (window.internals)
internals.settings.setCanvasUsesAcceleratedDrawing(false);
</script>
<body>
<b>CanvasRenderingContext2D.drawImage() should ignore the image's EXIF orientation if its style image-orientation is set to "none".</b>
<br>
<br>
<div class ="container">
<div class ="box">
<canvas id="canvas1"></canvas>
</div>
<br>Normal
</div>
<div class ="container">
<div class ="box">
<canvas id="canvas2"></canvas>
</div>
<br>Flipped horizontally
</div>
<div class ="container">
<div class ="box">
<canvas id="canvas3"></canvas>
</div>
<br>Rotated 180&deg;
</div>
<div class ="container">
<div class ="box">
<canvas id="canvas4"></canvas>
</div>
<br>Flipped vertically
</div>
<br>
<div class ="container">
<div class ="box">
<canvas id="canvas5"></canvas>
</div>
<br>Rotated 90&deg; CCW and flipped vertically
</div>
<div class ="container">
<div class ="box">
<canvas id="canvas6"></canvas>
</div>
<br>Rotated 90&deg; CCW
</div>
<div class ="container">
<div class ="box">
<canvas id="canvas7"></canvas>
</div>
<br>Rotated 90&deg; CW and flipped vertically
</div>
<div class ="container">
<div class ="box">
<canvas id="canvas8"></canvas>
</div>
<br>Rotated 90&deg; CW
</div>
<br>
<div class ="container">
<div class ="box">
<canvas id="canvas9"></canvas>
</div>
<br>Undefined (invalid value)
</div>
<script>
Refactor TestOptions code in WebKitTestRunner to make it easier to rationalize and extend https://bugs.webkit.org/show_bug.cgi?id=217390 Reviewed by Darin Adler. Refactors TestOptions code in WebKitTestRunner to make it clear how options coming in at different levels are treated and what precedence each has. The order is (from least to most): - Global features passed to WebKitTestRunner via the command line (e.g. --show-touches) - Hardcoded features based on the path of the test being run (hopefully we can remove all soon) - Hardcoded platform specific defaults (currently only used by macOS for useThreadedScrolling). - Features from the test headers within the test itself. - Finally, a second chance for more platform specific defaults (currenly only used the Cocoa ports for setting enableProcessSwapOnNavigation and enableProcessSwapOnWindowOpen based on NSUserDefaults.) To make this change work, and pave the way for future autogeneration of some of these test options, the TestOptions struct (now class) was overhauled. Instead of storing the state itself, TestOptions is now an immutable owner of a TestFeatures object. TestFeatures is a simple struct that contains maps of option keys to values and can be merged with other TestFeatures objects. TestOptions takes a TestFeatures at construction, and exposes getters for all keys, as well as defaults for when they are not in the maps. In future changes, I would like to remove many of these (the ones that correspond with WebKit preferences anyway) and have the keys and values automatically dealt with by WKPreferences. * WebKitTestRunner/Options.cpp: * WebKitTestRunner/Options.h: Switch to std::unordered_map for consistency and ease of conversion. * WebKitTestRunner/PlatformWebView.h: (WTR::PlatformWebView::viewSupportsOptions const): Update to call new TestOptions functions. * WebKitTestRunner/StringFunctions.h: (WTR::toWK): (WTR::toWTFString): Add conversions for std::string. * WebKitTestRunner/TestController.h: * WebKitTestRunner/TestController.cpp: (WTR::TestController::initialize): Replace some bools with a new global TestFeatures instance that forms the base of all TestFeatures merges. (WTR::TestController::generateContextConfiguration const): (WTR::TestController::generatePageConfiguration): (WTR::TestController::createWebViewWithOptions): (WTR::TestController::ensureViewSupportsOptionsForTest): (WTR::TestController::resetPreferencesToConsistentValues): (WTR::TestController::resetStateToConsistentValues): Update to call new TestOptions functions. (WTR::TestController::createTestURL): Expose as a static member function on TestController for use in other files. (WTR::TestController::testOptionsForTest const): Rework to be a sequence of TestFeatures merges. (WTR::TestController::updateWebViewSizeForTest): (WTR::TestController::updateWindowScaleForTest): Update to call new TestOptions functions. (WTR::createTestURL): Deleted. (WTR::parseBooleanTestHeaderValue): Deleted. (WTR::parseStringTestHeaderValueAsRelativePath): Deleted. (WTR::parseStringTestHeaderValueAsURL): Deleted. (WTR::updateTestOptionsFromTestHeader): Deleted. (WTR::TestController::platformAddTestOptions const): Deleted. Moved TestOptions parsing to TestOptions.cpp * WebKitTestRunner/TestInvocation.cpp: (WTR::TestInvocation::createTestSettingsDictionary): Update to call new TestOptions functions. * WebKitTestRunner/TestOptions.h: Reworks TestOptions to be an immutable owner of a TestFeatures struct, which is a set of maps that map feature string keys, to values of type bool, double, string or string vector. * WebKitTestRunner/TestOptions.cpp: (WTR::merge): Merges two TestFeatures objects. If both contain the same key, the 'additional' TestFeatures overrides the 'base' TestFeatures. (WTR::dumpFeatures): Helper to dump features to stderr, useful for debugging. (WTR::keyType): Helper for parser to know which value parser to use. (WTR::parseBooleanTestHeaderValue): (WTR::parseStringTestHeaderValueAsRelativePath): (WTR::parseStringTestHeaderValueAsURL): Value parsers moved from TestController.cpp (WTR::parseTestHeader): Header parser moved from TestController.cpp. Update to now return a TestFeatures object and use keyType to pick value parser rather than inlining the if statements. (WTR::hardcodedFeaturesBasedOnPathForTest): Moved from the TestOptions contructor and reworked to return a TestFeatures object to be merged by the caller. (WTR::featureDefaultsFromTestHeaderForTest): Creates a TestFeatures for the test headers of the current test. * WebKitTestRunner/cocoa/TestControllerCocoa.mm: (WTR::TestController::platformSpecificFeatureOverridesDefaultsForTest const): Reworked to now return a TestFeatures object that will be merged, rather than updating a TestOptions. Moves enableInAppBrowserPrivacy work to TestController::platformWillRunTest where it is more appropriate. (WTR::TestController::platformInitializeDataStore): (WTR::TestController::platformCreateWebView): (WTR::TestController::finishCreatingPlatformWebView): (WTR::TestController::setApplicationBundleIdentifier): (WTR::TestController::cocoaResetStateToConsistentValues): (WTR::contentMode): Update to call new TestOptions functions. * WebKitTestRunner/ios/TestControllerIOS.mm: (WTR::TestController::platformResetStateToConsistentValues): (WTR::TestController::platformConfigureViewForTest): Update to call new TestOptions functions. (WTR::TestController::platformSpecificFeatureDefaultsForTest const): (WTR::TestController::updatePlatformSpecificTestOptionsForTest const): Deleted. Moved GeneratedTouchesDebugWindow work to TestController::platformConfigureViewForTest where it is more appropriate and removed shouldShowTouches setting as that is done globally now. * WebKitTestRunner/mac/PlatformWebViewMac.mm: (WTR::PlatformWebView::PlatformWebView): Update to call new TestOptions functions. * WebKitTestRunner/mac/TestControllerMac.mm: (WTR::TestController::platformSpecificFeatureDefaultsForTest const): (WTR::TestController::updatePlatformSpecificTestOptionsForTest const): Deleted. Remove shouldUseRemoteLayerTree and shouldShowWebView, as those are now done globally, and re-implemented useThreadedScrolling to use boolFeatures. * WebKitTestRunner/win/TestControllerWin.cpp: (WTR::TestController::platformSpecificFeatureDefaultsForTest const): (WTR::TestController::updatePlatformSpecificTestOptionsForTest const): Deleted. Updated for new signature. * WebKitTestRunner/wpe/TestControllerWPE.cpp: (WTR::TestController::platformSpecificFeatureDefaultsForTest const): (WTR::TestController::updatePlatformSpecificTestOptionsForTest const): Deleted. Updated for new signature. * WebKitTestRunner/gtk/TestControllerGTK.cpp: (WTR::TestController::platformSpecificFeatureDefaultsForTest const): (WTR::TestController::updatePlatformSpecificTestOptionsForTest const): Deleted. Updated for new signature. Canonical link: https://commits.webkit.org/230271@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@268238 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-10-09 00:45:29 +00:00
if (window.internals)
internals.settings.setCanvasUsesAcceleratedDrawing(false);
if (window.testRunner)
window.testRunner.waitUntilDone();
window.onload = function() {
var image = new Image;
image.src = "resources/exif-orientation-1-ul.jpg";
image.decode().then(() => {
let canvases = document.querySelectorAll("canvas");
for (const canvas of canvases) {
canvas.width = canvas.offsetWidth - 2;
canvas.height = canvas.offsetHeight - 2;
let context = canvas.getContext("2d");
context.drawImage(image, 0, 0, canvas.width, canvas.height);
}
if (window.testRunner)
window.testRunner.notifyDone();
});
}
</script>
</body>