<!DOCTYPE html>
<html>
<body>
<script src="../../resources/js-test-pre.js"></script>
<script>
description('Test that clip-path shapes accept different length units');

function computedStyle(property, value) {
    var div = document.createElement("div");
    document.body.appendChild(div);
    div.style.setProperty(property, value);
    var computedValue = getComputedStyle(div).getPropertyValue(property);
    document.body.removeChild(div);
    return computedValue;
}

function innerStyle(property, value) {
    var div = document.createElement("div");
    div.style.setProperty(property, value);
    return div.style.getPropertyValue(property);
}

function testComputed(property, value, expected) {
    shouldBeEqualToString('computedStyle("' + property + '", "' + value + '")', expected);
}

function testInner(property, value, expected) {
    if (expected === null)
        expected = "";
    shouldBeEqualToString('innerStyle("' + property + '", "' + value + '")', expected);
}

function negativeTest(property, value) {
    testInner(property, value, null);
    // FIXME: Computed style not yet implemented.
    // testComputed(property, value, 'none');
}

// test mask-image
testInner("-webkit-mask", "none", "none");
testInner("-webkit-mask", "none, none", "none, none");
testInner("-webkit-mask", "none, none, none", "none, none, none");
testInner("-webkit-mask", "url(file:///image.png), none", "url(\"file:///image.png\"), none");
testInner("-webkit-mask", "none, url(file:///image.png)", "none, url(\"file:///image.png\")");


// test mask-position
testInner("-webkit-mask", "top left", "left top");
testInner("-webkit-mask", "bottom right", "right bottom");
testInner("-webkit-mask", "left bottom", "left bottom");
testInner("-webkit-mask", "right top", "right top");
testInner("-webkit-mask", "center", "center");
testInner("-webkit-mask", "none top", "top");
testInner("-webkit-mask", "none bottom", "bottom");
testInner("-webkit-mask", "none right", "right");
testInner("-webkit-mask", "none top right", "right top");
testInner("-webkit-mask", "none bottom left", "left bottom");
testInner("-webkit-mask", "none right", "right");
testInner("-webkit-mask", "none left", "left");
testInner("-webkit-mask", "center 50%", "center 50%");
testInner("-webkit-mask", "50px 50%", "50px 50%");
testInner("-webkit-mask", "center left", "left");
testInner("-webkit-mask", "top center", "top");
testInner("-webkit-mask", "left 10px top 15px", "left 10px top 15px");
testInner("-webkit-mask", "left 10% top 30%", "left 10% top 30%");
testInner("-webkit-mask", "right top 15px", "right top 15px");
testInner("-webkit-mask", "left 10px center", "left 10px center");
testInner("-webkit-mask", "center top 20px", "center top 20px");
testInner("-webkit-mask", "center left 30px", "left 30px center");
testInner("-webkit-mask", "left 20% top", "left 20% top");
testInner("-webkit-mask", "center center", "center");

testInner("-webkit-mask-position", "left 10px top 15px", "left 10px top 15px");
testInner("-webkit-mask-position", "left 10% top 30%", "left 10% top 30%");
testInner("-webkit-mask-position", "right top 15px", "right top 15px");
testInner("-webkit-mask-position", "left 10px center", "left 10px center");
testInner("-webkit-mask-position", "center top 20px", "center top 20px");
testInner("-webkit-mask-position", "center left 30px", "left 30px center");
testInner("-webkit-mask-position", "left 20% top", "left 20% top");

testInner("-webkit-mask-position", "0%", "0%");
testInner("-webkit-mask-position", "0% 0%", "0% 0%");
testInner("-webkit-mask-position", "0% center", "0%");
testInner("-webkit-mask-position", "center 0%", "center 0%");
testInner("-webkit-mask-position", "20% 0%", "20% 0%");
testInner("-webkit-mask-position", "0% 20%", "0% 20%");

testInner("-webkit-mask-position-x", "left", "left");
testInner("-webkit-mask-position-y", "top", "top");

// test mask-source-type
testInner("-webkit-mask", "none alpha", "alpha");
testInner("-webkit-mask", "none luminance, none alpha", "luminance, alpha");
testInner("-webkit-mask", "none auto, none, none luminance", "none, none, luminance");
testInner("-webkit-mask-source-type", "alpha", "alpha");
testInner("-webkit-mask-source-type", "luminance", "luminance");
testInner("-webkit-mask-source-type", "auto", "auto");
testComputed("-webkit-mask-source-type", "alpha", "alpha");
testComputed("-webkit-mask-source-type", "auto", "alpha");
testComputed("-webkit-mask-source-type", "luminance", "luminance");
testComputed("-webkit-mask-source-type", "", "alpha");

// test mask-repeat
testInner("-webkit-mask", "repeat-x", "repeat-x");
testInner("-webkit-mask", "repeat-y", "repeat-y");
testInner("-webkit-mask", "repeat", "repeat");
testInner("-webkit-mask", "space", "space");
testInner("-webkit-mask", "no-repeat", "no-repeat");
testInner("-webkit-mask", "repeat space", "repeat space");
testInner("-webkit-mask", "repeat round", "repeat round");
testInner("-webkit-mask", "repeat no-repeat", "repeat-x");
testInner("-webkit-mask", "repeat space, repeat-x", "repeat space, repeat-x");
testInner("-webkit-mask", "repeat none", "repeat");
testInner("-webkit-mask", "none repeat", "repeat");

// test mask-origin / mask-clip
testInner("-webkit-mask", "padding-box", "padding-box");
testInner("-webkit-mask", "border-box", "none");
testInner("-webkit-mask", "content-box", "content-box");
testInner("-webkit-mask", "padding-box none", "padding-box");
testInner("-webkit-mask", "none padding-box", "padding-box");
testInner("-webkit-mask", "padding-box content-box", "padding-box content-box");
testInner("-webkit-mask", "content-box content-box", "content-box");
testInner("-webkit-mask", "padding-box border-box", "padding-box border-box");
testInner("-webkit-mask", "padding-box border-box none", "padding-box border-box");
testInner("-webkit-mask", "none padding-box border-box", "padding-box border-box");

// test mask-size
testInner("-webkit-mask", "none left top / auto", "left top");
testInner("-webkit-mask", "none left top / auto auto", "left top");
testInner("-webkit-mask", "none left top / 100%", "left top / 100%");
testInner("-webkit-mask", "none left top / 100% 100%", "left top / 100% 100%");
testInner("-webkit-mask", "none left top / 0%", "left top / 0%");
testInner("-webkit-mask", "none left top / auto 0%", "left top / auto 0%");
testInner("-webkit-mask", "none left top / cover", "left top / cover");
testInner("-webkit-mask", "none left top / contain", "left top / contain");
testInner("-webkit-mask", "none left 20px top 10px / contain", "left 20px top 10px / contain");
testInner("-webkit-mask", "none left 20px top / contain", "left 20px top / contain");

// combinations
testInner("-webkit-mask", "none padding-box content-box", "padding-box content-box");
testInner("-webkit-mask", "none padding-box", "padding-box");
testInner("-webkit-mask", "none top", "top");
testInner("-webkit-mask", "none center right 20px", "right 20px center");
testInner("-webkit-mask", "none border-box left top", "left top");
testInner("-webkit-mask", "none border-box left top 20px", "left top 20px");
testInner("-webkit-mask", "none border-box content-box left top repeat-x", "left top repeat-x border-box content-box");
testInner("-webkit-mask", "none border-box content-box left top repeat-x", "left top repeat-x border-box content-box");
testInner("-webkit-mask", "none border-box content-box right 0px center repeat-x", "right 0px center repeat-x border-box content-box");

// FIXME: Computed style not yet implemented.
// testComputed("-webkit-mask", "", "");
// https://bugs.webkit.org/show_bug.cgi?id=103021

// negative tests
negativeTest("-webkit-mask", "top none left");
negativeTest("-webkit-mask", "right none bottom");
negativeTest("-webkit-mask", "right right");
negativeTest("-webkit-mask", "left left");
negativeTest("-webkit-mask", "top top");
negativeTest("-webkit-mask", "bottom bottom");
negativeTest("-webkit-mask", "50% none 50%");
negativeTest("-webkit-mask", "repeat-x repeat-x");
negativeTest("-webkit-mask", "space repeat-y");
negativeTest("-webkit-mask", "repeat space space");
negativeTest("-webkit-mask", "padding-box border-box content-box");
negativeTest("-webkit-mask", "none / auto");
negativeTest("-webkit-mask", "none repeat-x / auto");
negativeTest("-webkit-mask", "none border-box / auto");
negativeTest("-webkit-mask", "none top left / cover 100%");
negativeTest("-webkit-mask", "scroll");
negativeTest("-webkit-mask", "fixed");
negativeTest("-webkit-mask", "local");
negativeTest("-webkit-mask", "space scroll");
negativeTest("-webkit-mask", "none scroll");
negativeTest("-webkit-mask", "none top left / auto repeat-x scroll border-box border-box");
negativeTest("-webkit-mask", "right top left");
negativeTest("-webkit-mask", "center left center");
negativeTest("-webkit-mask", "center top center");
negativeTest("-webkit-mask", "center right bottom");
negativeTest("-webkit-mask", "top solid bottom");
negativeTest("-webkit-mask", "none top left right center top / auto repeat-x scroll border-box border-box");
negativeTest("-webkit-mask", "none center center 20px / auto repeat-x scroll border-box border-box");
negativeTest("-webkit-mask", "none top 20px right 30px center / auto repeat-x scroll border-box border-box");
negativeTest("-webkit-mask", "none top 20px top 30px / auto repeat-x scroll border-box border-box");
negativeTest("-webkit-mask", "none top 20px bottom / auto repeat-x scroll border-box border-box");
negativeTest("-webkit-mask", "none alpha, none auto alpha");
negativeTest("-webkit-mask", "none alpha luminance");
negativeTest("-webkit-mask-source-type", "rubbish");
negativeTest("-webkit-mask-source-type", "");
negativeTest("-webkit-mask-source-type", "center");
negativeTest("-webkit-mask-source-type", "repeat");
negativeTest("-webkit-mask-repeat-x", "repeat");
negativeTest("-webkit-mask-repeat-y", "repeat");

</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>
